Error in Timestamp Microservice project

Error in Timestamp Microservice project

getting error in the test “It should return the expected error message for an invalid date”

i have Checked with an invalid date, the result was giving the expected json. help here

app.get("/api/timestamp/", (req, res) => {
  res.json({ unix:, utc: Date() });

app.get("/api/timestamp/:date_string", (req, res) => {
  let dateString = req.params.date_string;

  //A 4 digit number is a valid ISO-8601 for the beginning of that year
  //5 digits or more must be a unix time, until we reach a year 10,000 problem
  if (/\d{5,}/.test(dateString)) {
    let dateInt = parseInt(dateString);
    //Date regards numbers as unix timestamps, strings are processed differently
    res.json({ unix: dateString, utc: new Date(dateInt).toUTCString() });

 else {
    let dateObject = new Date(dateString);

    if (dateObject.getTime()) {
      res.json({ unix: dateObject.valueOf(), utc: dateObject.toUTCString() });
    } else {
      res.json({"unix": null, "utc" : "Invalid Date" });
1 Like

P.S. This was a Glitch bug, after reloading the page, the tests passed.

Same happens to me

I’ve tried

res.json({"unix": conv.getTime(), "utc": conv.toUTCString() });
res.json({ error: "Invalid Date" });
res.json({"unix": unix, "utc" : utc ,error: "Invalid Date"});
res.json({"unix": unix, "utc" : utc });
res.json({"unix": null, "utc" : "Invalid Date" });

But it doesn’t pass. Somebody noted that the error in the console was this:

frame-runner.js:70 TypeError: Cannot read property 'toLowerCase' of undefined at Object.eval (eval at _callee$ (frame-runner.js:63), <anonymous>:1:121) at s (jquery.js:3557) at f (jquery.js:3625)

If I inspect the code in the DevTools, the error happens during the eval of this code:
getUserInput => $.get(getUserInput('url') + '/api/timestamp/this-is-not-a-date').then(data => { assert.equal(data.error.toLowerCase(), 'invalid date');}, xhr => { throw new Error(xhr.responseText); })

For some reason data.error is undefined during the test.

Here is a similar discussion: [SOLVED] HELP REQUEST - Timestamp Microservice

Source code:

I’m starting to suspect it’s some glitch problem. The source code is different from the actual code in my glitch repository.