January 2018
Beginner
658 pages
13h 10m
English
There's is another way to represent our entire if block code. The following is an updated code snippet, and we can actually replace everything we have in the current callback function with this code:
if (!error && response.statusCode === 200) { console.log(body.currently.temperature);} else { console.log('Unable to fetch weather.');}
This condition checks if there is no error and the response status code is a 200, if that's the case what do we do? We simply print the temperature like we were doing last time, that was in the else if clause at the very bottom. Now we have an else case in the updated code snippet, so if there is an error or the status code is not a 200, we'll go ahead and print this message to the ...