question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove solutions from forum hint articles?

See original GitHub issue

Edited by @moT01:

I hope you don’t mind @qaz6209031, but I am changing this issue to discuss the removal of the solutions in the hints. I fixed the original issue described below, see the conversation for the new direction of the issue.

Describe your problem and how to reproduce it:

There are several bugs in freeCodeCamp Challenge Guide: Timestamp Microservice Solutions section All these bugs can be reproduced by submiting the timestamp project with the solution in the hint

This first bug is a typo

 if (dateObject.toString() === "Invalid Date") {
    res.json({ error: "Invaid Date" });
 }

res.json({ error: "Invaid Date" }) should change to res.json({ error: "Invalid Date" })

The second bug is

if (/\d{5,}/.test(dateString)) {
    dateInt = parseInt(dateString);
    //Date regards numbers as unix timestamps, strings are processed differently
    res.json({ unix: dateString, utc: new Date(dateInt).toUTCString() });
}

The res.json({ unix: dateString, utc: new Date(dateInt).toUTCString() }); } should change to res.json({ unix: dateInt, utc: new Date(dateInt).toUTCString() }); } since unix field is expecting a number not a string

The third bug is a runtime error Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client, I think the original solution is calling res.json() twice if we do a get request on projecturl/api/timestamp/1451001600000 So the simplest way to fix this in my opinion is just add a else condition like the following

if (/\d{5,}/.test(dateString)) {
    dateInt = parseInt(dateString);
    //Date regards numbers as unix timestamps, strings are processed differently
    res.json({ unix: dateInt, utc: new Date(dateInt).toUTCString() });
} else {
    let dateObject = new Date(dateString);

    if (dateObject.toString() === "Invalid Date") {
      res.json({ error: "Invalid Date" });
    } else {
      res.json({ unix: dateObject.valueOf(), utc: dateObject.toUTCString() });
    }
}

Add a Link to the page with the problem: freeCodeCamp Challenge Guide: Timestamp Microservice

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:30 (30 by maintainers)

github_iconTop GitHub Comments

1reaction
vipranarayan14commented, Jun 2, 2021

I have submitted a PR with the required changes.

1reaction
vipranarayan14commented, May 31, 2021

Thank you, @ieahleen. I was actually waiting for someone to assign me the issue. Now I understand. I will go through the contributing docs and also submit the PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove Suggestion from Short Description - ServiceNow
Solved: I created an app extended from task table. I reused short description field. Is there a way to hide the suggestion button...
Read more >
Removing Unnecessary Fields - Tips and Tricks
Hi @Aaron_Sinclair, welcome to the Asana Community Forum! You can currently remove field from a project following the steps in this article: ...
Read more >
How do I remove unwanted username suggestions at login ...
Chosen solution​​ Here's how to delete unwanted username suggestions and email address suggestions at login boxes: 1: Click on the empty username ...
Read more >
Wix Forum: Deleting Your Forum | Help Center | Wix.com
Click Menus & Pages on the left side of the Editor. Hover over your forum page and click the Show More icon. Click...
Read more >
Forum - IBM
No information is available for this page.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found