Tell us what’s happening:
Hi, I think that I’ve realese all what is demanded in the chalnge but whenI submit it inform me that no one from the parts of the chanlenge was correct.
here’s my code.
require('dotenv').config();
var express = require('express');
var ip = require('ip');
var app = express();
var {detect} = require('detect-browser');
var browser = detect();
var window = require('window');
// enable CORS (https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
// so that your API is remotely testable by FCC
var cors = require('cors');
app.use(cors({optionsSuccessStatus: 200})); // some legacy browsers choke on 204
// http://expressjs.com/en/starter/static-files.html
app.use(express.static('public'));
// http://expressjs.com/en/starter/basic-routing.html
app.get("/", function (req, res) {
res.sendFile(__dirname + '/views/index.html');
});
// your first API endpoint...
app.get("/api/hello", function (req, res) {
res.json({greeting: 'hello API'});
});
app.get("/api/whoami", (req,res)=>{
const ipadr = ip.address();
const Blanguage = req.headers["accept-language"].substring(0,14);
return res.json({ipaddress: ipadr, language: Blanguage, software: req.headers['user-agent']});
})
// listen for requests :)
var listener = app.listen(process.env.PORT, function () {
console.log('Your app is listening on port ' + listener.address().port);
});
can some one help please.
Your project link(s)
solution: http://localhost:49929/api/whoami
githubLink: https://github.com/MohamedZouh/boilerplate-project-headerparser.git
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36
.
Challenge: Request Header Parser Microservice
Link to the challenge: