Back End Development and APIs Projects - Timestamp Microservice

Tell us what’s happening:
What am I missing to perform the checks? From my point of view it should pass them all.

solution: https://aduffner.de

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36

Challenge: Back End Development and APIs Projects - Timestamp Microservice

Link to the challenge:

Looks everything fine and I provide only the TLD (just for this post I linked /api/ to showcase functionality.

It seems like the checks are not working:

// running tests
A request to /api/:date? with a valid date should return a JSON object with a unix key that is a Unix timestamp of the input date in milliseconds (as type Number)
A request to /api/:date? with a valid date should return a JSON object with a utc key that is a string of the input date in the format: Thu, 01 Jan 1970 00:00:00 GMT
A request to /api/1451001600000 should return { unix: 1451001600000, utc: "Fri, 25 Dec 2015 00:00:00 GMT" }
Your project can handle dates that can be successfully parsed by new Date(date_string)
If the input date string is invalid, the API returns an object having the structure { error : "Invalid Date" }
An empty date parameter should return the current time in a JSON object with a unix key
An empty date parameter should return the current time in a JSON object with a utc key
// tests completed
// console output
[Error]
[Error]
[Error]
[Error]
jQuery.Deferred exception: Cannot read properties of undefined (reading 'error') TypeError: Cannot read properties of undefined (reading 'error')
    at Object.eval (eval at <anonymous> (https://www.freecodecamp.org/js/frame-runner-aa2f7283f73242fa4919.js:2:205058), <anonymous>:7:31)
    at c (https://www.freecodecamp.org/js/frame-runner-aa2f7283f73242fa4919.js:2:121282)
    at l (https://www.freecodecamp.org/js/frame-runner-aa2f7283f73242fa4919.js:2:121584) undefined
[TypeError: Cannot read properties of undefined (reading 'error')]
[Error]
[Error]

Look at the browser console when submitting the url to the FCC page.

I needed to add res.header('Access-Control-Allow-Origin', '*');, because of the following in the console:

Access to XMLHttpRequest at 'XXX' from origin 'https://www.freecodecamp.org' has been blocked by CORS policy: 
No 'Access-Control-Allow-Origin' header is present on the requested resource.

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