Back End Development and APIs Projects - URL Shortener Microservice

Tell us what’s happening:
Describe your issue in detail here.
The app is spamming out of control and won’t stop. I cant find the error but i believe it has something to do with Parser. Will someone help me please.

Your project link(s)

solution: boilerplate-project-urlshortener-1 - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

Challenge: Back End Development and APIs Projects - URL Shortener Microservice

Link to the challenge:

The following two tests specify that the url path for POST and GET requests are as follows:

  • You can POST a URL to /api/shorturl and get a JSON response with original_url and short_url properties. Here’s an example: { original_url : 'https://freeCodeCamp.org', short_url : 1}
  • Waiting:When you visit /api/shorturl/<short_url>, you will be redirected to the original URL.

Note the API url paths, /api/shorturl and the /api/shorturl/<short_url> for the POST and the GET requests.

But, your Replit code (index.js) doesn’t have routes with those paths.

Ok I didn’t see that . I have to to be careful when i use find and replace . however its still spamming out of control.

You need to be specific about the issue you are facing with your app.

Are there any errors in the console? When you start the app what happens? What happens when you do a GET or POST request?

Please include the errors (maybe screenshots), or error stack trace, etc., so that any issue can be addressed.

its spamming . running out of control and won’t stop plus its not passing test.

That is not a very helpful description of what is wrong.


You are not using a DB in your code but you have this:

let url = mongoose.connect(process.env.MONGO_DB, {userNewUrlParse: true, useUnifiedTopology: true});

Did you add the connection string to the secrets? Otherwise, it will just keep crashing and restarting.


Your URL validation is not going to work. The dns.lookup methods only accepts the hostname (docs). You can use the URL constructor to get the hostname new URL(url).hostname

The tests never hit the api/shorturl/:id endpoint, look at your other route and compare the path.

Log out link after the find


I would suggest using the DB and not an array for this.

Yes i have it in secret and yes it is crashing . I called it spamming. Sorry for confusion. :grinning:

Comment out the mongoose.connect part of the code. Does it still crash?