console.log('Hello world!')$ node index.js
Hello world!var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Wazzup?')
})
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
})$ node .
Example app listening on port 3000!app.get('/hey', function (req, res) {
res.send('Hey Yourself!')
})getpostman.com
var body_parser = require('body-parser')
app.use(body_parser.urlencoded({extended: false}))
app.use(body_parser.json())app.post('/send-info', function (req, res) {
res.json({
message: req.body.info ? `info was ${req.body.info}` : 'No info!'
})
}){
"Key": "value",
"another_key": "Another value",
"numbers": [1, 2, 3, 4],
"collection": [
{
"key": "value",
"some_other_key": "some other value"
},
{
"key": "potatoes",
"some_other_key": "bananas"
}
]
}