Timestamp Microservice not passing tests

Tell us what’s happening:
I don’t know why the project is not passing the tests, in repl.it everything seems correct.
https://repl.it/@hussein_odeh/boilerplate-project-timestamp
https://github.com/husseinodeh/boilerplate-project-timestamp

Your code so far

app.get("/api/timestamp/:date_string?", (req,res) => {
  date_string = req.params.date_string;
  if(!date_string) { //If there is no parameter
    date = new Date();
    res.json({"unix": date.getTime(), "utc": date.toUTCString()});
  }
  else
  {  
    if(!isNaN(date_string)) //If the parameter is a date in milliseconds
      date = new Date(Number(date_string));
    else 
      date = new Date(date_string);
    if(date instanceof Date && !isNaN(date)) //If the date is valid
      res.json({"unix": date.getTime(), "utc": date.toUTCString()});
    else 
      res.json({"error" : "Invalid Date" });
  
  }
});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36.

Challenge: Timestamp Microservice

Link to the challenge:

I can’t get your live project page to display (bad response with SSL error in chrome), and I would bet it’s something to do with the missing braces in this block.

1 Like

The braces are not needed, in this situation, although it could be a good practice…

The problem was that I was putting https://boilerplate-project-timestamp-hussein_odeh.repl.co instead of https://boilerplate-project-timestamp–hussein_odeh.repl.co with double ‘-’ when I tried to pass the tests, I keep forgetting that.

Now all the test passed.
Is strange, because I passed all the tests a couple of weeks ago, but now I checked and it is not registered as passed…

Any idea why?

You’re correct. I should have checked first, but I thought (hoped) that only worked with a one-line if statement. I always use braces and try to forget that you don’t have too.

I have no idea why it would not be registered as long as it passed the tests and you clicked the submit and go to next project button.