Skip to content

Instantly share code, notes, and snippets.

@numfin
Created March 29, 2018 11:59
Show Gist options
  • Save numfin/35131ac8f1134c7b1e63d18b25b41b11 to your computer and use it in GitHub Desktop.
Save numfin/35131ac8f1134c7b1e63d18b25b41b11 to your computer and use it in GitHub Desktop.
const auth = require(`./auth.js`)
const port = 3000
const request = require('request')
// require your modules
const express = require('express')
const bodyParser = require('body-parser')
// create instance of express
let app = express()
// let app use body-parser
// this one is parsing application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// this one is parsing application/json
app.use(bodyParser.json())
app.get('/', (req, res) => {
res.end('sup bitches')
})
// POST endpoint /form
app.post('/form', (req, res) => {
// log sent body
console.log(req.body)
// pass 'hello' back after request
res.send('hello')
})
// listen on port 3000
app.listen(3000, () => {
console.log('Running on *:3000')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment