January 2018
Beginner
658 pages
13h 10m
English
The first thing we'll do is add an if statement as shown below, checking if the error object exists:
request({ url: `https://maps.googleapis.com/maps/api/geocode/json?address=${encodedAddress}`, json: true}, (error, response, body) => { if (error) { }
This will run the code inside of our code block if the error object exists, if it doesn't fine, we'll move on into the next else if statement, if there is any.
If there is an error, all we'll do is add a console.log and a message to the screen, something like Unable to connect to Google servers:
if (error) { console.log('Unable to connect Google servers.');}
This will let the user know that we were unable to connect to the user servers, not that something ...