tami-events/src/index.ts

32 lines
613 B
TypeScript
Raw Normal View History

2023-04-21 20:57:53 +03:00
import express from 'express'
import { body, headers } from './eventsRequest'
import dotenv from 'dotenv'
dotenv.config()
const PORT = process.env.PORT
const app = express()
app.get('/events', (req, res) => {
fetch('https://api.meetup.com/gql', {
method: 'POST',
headers,
body,
})
.then((response) => {
return response.json()
})
.then((events) => {
res.status(200)
res.send(events)
})
.catch((err) => {
res.status(400)
res.send('Something went wrong')
})
})
app.listen(PORT, () => {
console.log(`server is listening on port ${PORT}`)
})