FCC Task:
In the following exercise we are going to receive data from a POST request.
Build an API endpoint, mounted at **GET /name**
.
Respond with a JSON document, taking the structure **{ name: 'firstname lastname'}**
. The first and last name parameters should be encoded in a query string e.g. ?first=firstname&last=lastname
If you want you can use the method:
app.route(path).get(handler).post(handler)
Chaining answer:
app.route('/name').get(function(req,res) {
const firstname = req.query.first;
const lastname =req.query.last;
res.send({"name":firstname + " " + lastname})
}).post();
My Questions:
- Receiving data from a POST request, means that someone has POSTED a request to this API for data. Would this not be a GET request?
- The API is responding with a response object?
- Why is there no handler defined for the post()?
- Should
res.send({"name":firstname + " " + lastname})
not be inside the post()?
I’m getting confused as to who is POSTING, GETTING?