DEV Community

Discussion on: Anyfiddle - JSFiddle but for any language. Build, run and share code with this online code editor

Collapse
 
yoursunny profile image
Junxiao Shi

I'm seeing this on My Projects page:

Untitled Project
Last active Invalid date

/api/projects/ endpoint returned the following for this project:

[
   {
      "isPublic":true,
      "state":"STARTED",
      "desiredState":"STARTED",
      "reasonForState":"USER_ACTION",
      "saveState":"SAVED",
      "isForked":false,
      "id":"9r7y78cu",
      "userId":"b127815a-417c-412c-aeac-12598bbe4dad",
      "title":"Untitled Project",
      "description":null,
      "image":"registry.anyfiddle.com/projects/x4ku9su6",
      "port":null,
      "parentTemplateId":"nodejs",
      "parentProjectId":"x4ku9su6",
      "lastPingAt":null,
      "lastActiveAt":null,
      "lastStartedAt":"2020-09-03T23:35:14.000Z",
      "createdAt":"2020-09-03T23:35:05.839Z",
      "parentTemplate":{
      }
   }
]

The good thing is that the frontend elegantly handled this backend error by translating "lastActiveAt": null to "Invalid date" instead of crashing. Call me irresponsible if I crash on null or undefined in JavaScript or TypeScript.

Collapse
 
jojimail profile image
Joji Augustine

Last active being null has a reason. Its not an error. UI will understand this.

Collapse
 
yoursunny profile image
Junxiao Shi

It’s better to render as “Never” instead of “Invalid date”.