URL Shortener test always times out

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.

Challenge: URL Shortener Microservice

Link to the challenge:

Welcome, furko.

I am not sure if this is the problem, but you have a bit of a conflicting pattern here:

const newUrl = new Url({
          original_url: postedUrl,
          short_url: urlIndex++
        newUrl.save(function (error, url) {

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 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
  • this is the domain name: freecodecamp.org

Hope this helps

1 Like

Thank you so much. Looks like this was the problem indeed .