This is a straight-forward challenge and a very simple way to tackle it is to break it down and follow the steps:
Define an object (obj) which will hold the response you will send. In the object provide the keys which you will assign values to.
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.
Return the object as the last part of the callback function.
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
iii. The software information is also located in the headers object. To get the value for the “software” key, use
iv. Finally, send the result in JSON format using
res.json(obj), and you’re done!
Challenge: Request Header Parser Microservice
Link to the challenge: