Tell us what’s happening:
Hello. I’m trying to solve the URL Shortener Microservice project, and it is failing the automated tests, but I cannot figure out why, as it correct actions are performed when I test in my browser.
Specifically, it fails the second test: “POST a URL to /api/shorturl and get a JSON response with original_url and short_url properties.”, and the third test: “When you visit /api/shorturl/<short_url> , you will be redirected to the original URL.”
I suggest you console.log the first argument you are passing into dns.lookup, then look at the documentation for dns.lookup, and look at a few examples if need be.
Otherwise, make use of the browser devtools to see the network requests made by the freeCodeCamp tests.
Thank you @Sky020, I’ll give that a try. As far as I can tell I am using dns.lookup correctly, and the domain name (passed in as the first parameter) is appearing in the console as expected.
I would really double check that. If you get errors from valid addresses, it is because you are not passing in the correct argument. This is what I see:
Ah, understood! I rechecked and adjusted the dns.lookup argument to provide just the hostname (without query string) as it had allowed previously. The console is now showing only what appear to be valid hostnames: e.g. ‘boilerplate-project-urlshortener.jordash.repl.co’ Do you see anything else that isn’t correct? It’s still failing the checks.
Yes, I finally got it!! I was stripping off the protocol to pass to the dns.lookup, but not adding it back before returning the original_url in the json response. Thank you so much for your hints, it is now passing the tests!