Hint for: Request Header Parser Microservice with Node and Express Challenge

This is a straight-forward challenge and a very simple way to tackle it is to break it down and follow the steps:

Step 1:
Define an object (obj) which will hold the response you will send. In the object provide the keys which you will assign values to.

Step 2:
Create the callback function for the get request to the specified endpoint (/api/whoami) and assign the appropriate values to the keys you have defined in step one above in the function body.

Step 3:
Return the object as the last part of the callback function.

Further hints:
i. To get your IP address, use the command req.ip, and assign it to the IP address key.

ii. Your language is located in the request header (to see the headers you can try logging req.headers to the console). To get the value of the language, use req.headers["accept-language"].

iii. The software information is also located in the headers object. To get the value for the “software” key, use req.headers["user-agent"].

iv. Finally, send the result in JSON format using res.json(obj), and you’re done!

Good luck! :slightly_smiling_face:

Challenge: Request Header Parser Microservice

Link to the challenge: