January 2018
Beginner
658 pages
13h 10m
English
To change our console.log into callback calls, for the first two console.log calls we can replace console.log with callback. And this will line up with the arguments that we specified in app.js, where the first one is the errorMessage and the second one is the weatherResults. In this case we'll pass the errorMessage back and the second argument is undefined, which it should be. We can do the same thing for Unable to fetch weather:
if (error) { callback('Unable to connect to Forecast.io server.');} else if (response.statusCode === 400) { callback('Unable to fetch weather.');}
Now the third console.log call will be a little more complex. We'll have to actually create an object instead of just passing ...
Read now
Unlock full access