Submission not working Timestamp problem

Hello,

In the Javascript, Microservices course I have been working on the timestamp project. So far I have finally been able to return all unix and utc values and reached all the requirements. Yet everytime I submit the link via localhost or repl none of the boxes are ticked. Am confused. Is there something wrong with my code or with the processing on freecodecamps end?

My code:

// your first API endpoint... 
app.get("api/timestamp/", (req,res) =>{
  const date = new Date();
  date.setMinutes(date.getMinutes()-3);
  res.json({ "unix": date.getTime(), "utc": date.toUTCString()})
});


app.get("/api/timestamp/:date", function(req, res) {
  
  let  date_params = new Date(req.params.date);
  const output = "";

  if(date_params.toString() == "Invalid Date"){
    date_params = new Date(parseInt(req.params.date));
  }
  
  if(date_params.toString() !== "Invalid Date"){
    output = res.json({ "unix": date_params.getTime(), "utc": date_params.toUTCString()});
  } else{
    res.json({ error: "Invalid Date"});
  }
  return output;
});

Where in the instructions does it tell you to have a GET route located at:
your-url.com/api/timestamp/

Look carefully at what the correct route should be.

Thank you so much. Took out all the “timestamp” references and just kept the date and :date stuff. Really have to read that carefully next time. I got almost everything right except the " An empty date parameter should return the current time in a JSON object with a unix key" and the one below it. Will work on that now.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.