Thursday, 18 April 2019

Task: RESTapi with a few get-requests that support head

Disclaimer: Im a total newbie to nodeJS.I have the task to create a simple REST api with express with a handful of get- and delete-requests. Every route should support head and I can test the requests with postman.I'm about to finish the task and it all works fine. The only thing that confuses me is the part of the task that says "every endpoint should support head". I do understand the concept of headers, which is that if the header gets requested, not the entire body but only the overall information about the body is sent back to the client.Now when I make a head request via postman I get a status 200, which means that things are fine. Is that enough "sign" that my get requests "support head"? If not, how would an implementation look like?To give you an example of one endpoint:router.get("/movies", (req, res) => {var allMovies = [ ]; // code that adds objects into the allMovies-array. res.send(allMovies); }How should I proceed here so that this endpoint "supports head"?Thx in advance.

Submitted April 18, 2019 at 09:48PM by JLeeOT

No comments:

Post a Comment