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.
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.
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.