URL Shortener Microservice - Help

I’m having trouble with the URL shortener challenge. For whatever reason it simply doesn’t check the second and third requirements, eventhough it works perfectly as intended.

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}

When you visit /api/shorturl/<short_url>, you will be redirected to the original URL.

Here is my code GitHub - RafaelSdeS/fccURLShortener

let idInDB = await URL.findOne({
    short_url: +paramUrl

It looks like you are coercing the ID to a number. But you define the property as a string in the schema:

const urlSchema = new Schema ({
  original_url: String,
  short_url: String

Have you looked at the values actually being saved in your database?

I tried changing the type to number, but still doens’t work. If you want to look at the code, I uptated it on github.

For your question, it did work and values were appearing in my database, they were strings of number, like “1”. Now they’re just a number, but, as I said, it doesn’t work.