Problem with URL Shortener (APIs and Microservices Projects)

at the /api/shorturl/new endpoint i have

return res.json({
        "original_url" : url,
        "short_url" : id
      });

and i got this json returned
urlshort

but why i got this result from the test ?
really wonder why, cause it’s literally match the result of the example project that given from the project description

// running tests
You can POST a URL to /api/shorturl/new 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.
// tests completed

Welcome, ashalfarhan.

Would you mind sharing a link to your project? It is difficult to debug, without any code.

Also, what happens when you

I’m using repl.it template that given
this is the source code

Two things to note:

  // remove http(s) with regex
  const noHTTPSurl = url.replace(/^https?:\/\//, '');

  // check if the url is valid
  dns.lookup(noHTTPSurl, (err) => {
  • dns.lookup only takes a domain name.
  • The noHTTPSurl variable is not only a domain name

Hope this clarifies

It works!, thanks for help me to solve this, dude.
What a nice moderator.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.