This is the boilerplate code for the Basic Node and Express Challenges. Instructions for working on these challenges start at https://www.freecodecamp.org/learn/apis-and-microservices/basic-node-and-express/
Last active
June 21, 2022 20:27
-
-
Save blangue/f3531664d11e30c15d79ddc256305b48 to your computer and use it in GitHub Desktop.
Basic Express query managment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let express = require('express'); | |
var bodyParser = require("body-parser"); | |
let app = express(); | |
app.use(bodyParser.urlencoded({extended : false})); | |
app.post('/name', (req,res,next)=>{ | |
res.json({name: req.body.first +" "+ req.body.last}); | |
next(); | |
}); | |
app.get( | |
"/now", | |
(req, res, next) => { | |
req.time = new Date().toString(); | |
next(); | |
}, | |
(req, res) => { | |
res.send({ | |
time: req.time | |
}); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment