Back End Development and APIs Projects - URL Shortener Microservice

Tell us what’s happening:
Describe your issue in detail here.
What could be the problem because I have done all the best I can but am stuck?
Kindly guide where necessary.
Will be grateful.

Your project link(s)

solution: boilerplate-project-urlshortener - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; TECNO KD7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Mobile Safari/537.36

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

Link to the challenge:

The POST route should be /api/shorturl

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}

It ain’t passing what could be the error again.

@onyangaemmanuel25 You were previously told by @lasjorg what the project expects for the POST route. You have not changed your code to reflect that.

Also, in the following line:

const something = dns.lookup(urlparser.parse(bodyurl).hostname, (error, address) => {

you reference urlparser, but you have not defined what urlparser is anywhere in your code. This is going to be a problem once you resolve the POST route issue.

I can see you have created a new Replit where again you are not using the correct path for the POST. It literally has to be /api/shorturl you do not have a choice in the matter.

The test will hit that endpoint and the form is using api/shorturl for the action attribute.


I have done what you said but nothing still happens

I have tried to change whatever you said but nothing happens even after that.

Tell us what’s happening:
Describe your issue in detail here.

When I copy the code generated by the shorturl, it doesn’t redirect me to the original url
What could be the problem.
Will be grateful.

Your project link(s)

solution: Glitch :・゚✧

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; TECNO KD7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Mobile Safari/537.36

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

Link to the challenge:

@onyangaemmanuel25 Did you start this project in the last couple of days or did you originally start it a couple of years back? Can you provide the GitHub repo link you imported into Glitch?

I ask these questions as your boilerplate does not have the correct index.html or README.md` Did you remix this from another Glitch project? If so, which one?

If you want to use Glitch for the project, you should import the latest version of the the boilerplate from GitHub to make sure you have the correct base code. The GitHub shown in the project instructions is https://github.com/freeCodeCamp/boilerplate-project-urlshortener.



That is what it’s now Showing in my console



Am now receiving this in my console please advice

I can’t really do much with that but it looks like a DB error. What is the name of the DB you added to the connection string?

Can you post your connection string without showing the password?

Also, the 8000 error code might be an auth error. Did you provide the correct username and password?


Where are you working on this now and what is the link?

The DB connection string is mongodb+srv://admin:@cluster0.rzk6wtt.mongodb.net/?retryWrites=true&w=majority

The link is https://boilerplate-project-urlshortener-1.emmanuelonyanga.repl.co

Add a DB name to the string. You should be able to pick whatever you like, but don’t use admin as the DB name (might cause issues).

mongodb+srv://username:password@cluster0.rzk6wtt.mongodb.net/DBNameHere?retryWrites=true&w=majority

Did you pick the admin username when you made it? Not sure if that username might be reserved for something (don’t know). Maybe try creating a new user and use a different name.

I used admin as the username when I created it

I have maneuvered a lot but am finally reaching where am meant to be
Here is the link https://boilerplate-project-urlshortener.emmanuelonyanga.repl.co to the project am failing the second last test
Kindly check where the problem could be and advice me on what to do
Thanks in advance



Attached are the console readings
When I copy the shorturl generated to the browser it doesn’t direct me to the original url
What could be the problem.

If I fork your project and use my own DB it passes for me. I don’t ever see the err URLMODELFIND log. Can you please log out the actual error and not just that string?

I would try deleting the collection on Atlas and see if that fixes it.

Let me try deleting the collection on atlas

Did you try logging the error you get?

How do I log out the error?