Tell us what’s happening:
Hey there , I have been working on URL shortener on API projects and the test (2 and 3) keeps times out no matter what I tried. If you can help I would really appreciate
app works without any errors Your code so far
Live app : https://parallel-caramel-colony.glitch.me/
source code: Glitch :・゚✧
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36.
You are saving the short_url property based on the global variable urlIndex. This is a bad idea, because every time your app refreshes, the urlIndex will refresh, but the database will still have all the old values. Thus, you will have duplicate values.
Actually, I believe your issue is here:
dns.lookup(postedUrl.substring(8),
dns.lookup expects only the domain name as the first argument. That means, in this url https://freecodecamp.org/example/location
you are passing this: freecodecamp.org/example/location