Tell us what’s happening:
I do not understand why I am not able to pass the freeCodeCamp test for Timestamp.
I am using Replit starter project.
I did the coding in the server.js file underneath the commented code, // your first API endpoint…
I am able to pass the first test, providing my own project on Replit. But I cannot seem to pass the other 7 tests below.
- Am I missing something?
- Do I have to include a Secret Environment Variable file?
- Is the server.js file the only place I do coding?
- Do I have to do something in the package-lock.json file or the package.json file?
- Is my code lacking something or have syntax errors?
I appreciate any help. Thanks
Your code so far
app.get("/api/timestamp/:timestamp", function (request, response) {
let timestamp = request.params.timestamp;
if(timestamp.match(/\d{5,}/)){
timestamp = +timestamp;
}
let date = new Date(timestamp);
if(date.toUTCString() == "Invalid Date"){
response.json({error: date.toUTCString()})
}
response.json({unix: valueOf() , utc: date.toUTCString() });
});
app.get("/api/timestamp/",(req, res) => {
let date = new Date();
response.json({unix: valueOf() , utc: date.toUTCString() });
})
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36
Challenge: Timestamp Microservice
Link to the challenge: