Solution of Request Header Parser Microservice

Req object contains the details of headers in headers property

We can easily access the headers details by

console.log(req.headers)

Project solution

app.get("/api/whoami", (req, res) => {
  let address = req.headers.host;
  let language = req.headers["accept-language"];
  let software = req.headers["user-agent"];
  res.json({ ipaddress: address, language: language, software: software });
});

Challenge: Request Header Parser Microservice

Link to the challenge: