Cant get the res.json to not show the quotes" in response key

Tell us what’s happening:

Cant get the (nodejs/express) res.json to not show the quotes" in response key

Your code so far

[https://repl.it/@AkashMankar/urlshortener#server.js](https://repl.it/@AkashMankar/urlshortener#server.js)
const errorResponse = { error: 'invalid url' };

urlValidate = (url, cb) => {
  try {
    const hostname = new URL(url).hostname;
    dns.lookup(hostname, (err) => {
      if (err) {
        cb(err, null);
      } else {
        cb(null, url);
      }
    });
  } catch (err) {
    cb(errorResponse, null);
  }
};

app.post('/api/shorturl/new', (req, res) => {
  const URL = req.body['url'];

  urlValidate(URL, (err, validURL) => {
    if (err) {

      console.log(errorResponse);
       res.json({ error: 'invalid url' });

    } else {
      createAndSaveURL(validURL, (err, data) => {
        if (err) {
          res.json({'error': `DB error: ${err}`});
        } else {
            res.json(data);
        }
      });
    }
  });
});

Output when I enter invalid URL comes like:-

{"error":"invalid url"}

and the challenge is asking for { error: 'invalid url' }

tried many things from stackexchange, nothing is working!! Kindly help.

Challenge: URL Shortener Microservice

Link to the challenge:

I don’t think that’s the issue here, when I run your app, it fails for a test case with url ftp:/john-doe.org which is an invalid URL but your app returns a 202 instead of error

dns.lookup doesn’t look for the protocol whether it is https, http or ftp, etc. You should be handling that in your code so that valid URLs are the one that starts with http ot https

Thanks,will look into it.