title: Returning reason for node-fetch query results not matching rather than giving undefined. nodejs node-fetch
body: <p>Note the API key has had the last characters removed as I was told not to post api keys linked to my personal account.</p>
  <p>I am working on getting weather results from openweathermap.org Everything seems to be working except if I input an invalid city name or area code it returns undefined. I would like to return a reason for the failure in the console.
  below are the dependencies being used:</p>
  <pre><code>  &quot;name&quot;: &quot;node-final-exercise&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;app.js&quot;,
    &quot;scripts&quot;: {
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;dependencies&quot;: {
      &quot;node-fetch&quot;: &quot;^2.6.1&quot;
    }
  }
  </code></pre>
  <p>heres the code snippet I'm working on right now.</p>
  <pre><code>   // Goals for project
  // API's    OpenWeatherMap api.openweathermap.org/data/2.5/weather?q=London,uk&amp;APPID=8d0f96c686dbab4b20d5dda13
  // API's zip code specific api.openweathermap.org/data/2.5/weather?zip={zip code},{country code}&amp;appid={API key}
  // a. use node app.js (areacode) to connect to weather api should also accept ( city ) and (state) like cleveland ohio
  // b. parse data from weather api
  // c. ouput JSON parsed data into a readable format in the console.
  
  const fetch = require(&quot;node-fetch&quot;);
  const city = process.argv.slice(2);
  (async () =&gt; {
    try {
      await fetch(
        `http://api.openweathermap.org/data/2.5/weather?q=${city}&amp;units=metric&amp;appid=8d0f96c686dbab4b20d5dda13`
      )
        .then((res) =&gt; res.json())
        .then((body) =&gt; console.log(body.main))
        .catch(error =&gt;{console.error(&quot;first catch error : &quot;, error)})     
    } catch (error) {
      console.error(&quot;error : &quot;,error.message);
    }
  })();
  </code></pre>
  <p><a href="https://i.stack.imgur.com/ieQja.png" rel="nofollow noreferrer">console results</a></p>