No Response Object? - Timestamp Microservice

Tell us what’s happening:
Not getting a response object when my API has no input. Here’s the code:

app.get("/api", (req, res) => {
  //no input
  console.log('no input')
  responseObject['unix'] = new Date().getTime
  responseObject['utc'] = new Date().toUTCString

The console logs yield the following respectively:

no input
{ unix: [Function: getTime], utc: [Function: toUTCString] }

The response is curious in that’s loggin a function and not the date, but it matches the code I have seen several other functioning solutions. I think the error is somewhere in that piece but I haven’t been able to parse out what the exact issue is!

Thanks in advance –

Your project link(s)

solution: http://localhost:64951

Your browser information:

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

Challenge: Back End Development and APIs Projects - Timestamp Microservice

Link to the challenge:

You did not call the methods. You just assigned the method (a function).

Also, be careful here because you are getting two slightly different dates because you are making to separate Date objects.

Thanks! I knew I overlooked something simple.

Added a

let now = new Date()

and corrected my response object calls.

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