Tell us what’s happening:
Unable to pass 3rd test required redirection to original url with short url. It works on my end if anyone can confirm? Not sure what is going on, have tried the same short urls sent by fcc test suite with success so i am not sure if it is requiring a certain function to pass.
POST /api/shorturl - ::ffff:172.18.0.1
{
original_url: 'https://boilerplate-project-urlshortener-5.jeremyagray.repl.co/?v=1629507441323',
short_url: 'd7Pb'
}
POST /api/shorturl - ::ffff:172.18.0.1
{
original_url: 'https://boilerplate-project-urlshortener-5.jeremyagray.repl.co/?v=1629507441552',
short_url: 'd7Pb'
}
which has repeats of the ID/short_url. Murphy’s law dictates the wrong one will invariably be returned every time unless randomly is harder to debug. The problem is
which I assume executes nanoid(4) once, not every time as you want.
This underscores the importance of logging all route inputs and outputs because the problem was found on a GET route but was caused on a POST route. Regrettably, I should be smart enough to follow my own advice, but instead of dutifully logging, I played with the GET route involved with the failing test until I thought “the only thing it can be is duplicate IDs” and then I looked at the DB and saw exactly that. But the logging I used after the fact makes me feel better.
You may have some other issues too. Make sure you return your responses every time (return res.json({...}) for example). I had to modify your CORS setting as well just to get the tests to fail properly.