January 2018
Beginner
658 pages
13h 10m
English
In our case, we'll be taking the address and getting the latitude and longitude. To make our request, we'll call a method available on axios, axios.get:
var geocodeUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${encodedAddress}`;axios.get
The get is the method that lets us make our HTTP get request, which is exactly what we want to do in this case. Also, it's really simple to set up. When you're expecting JSON data, all you have to do is to pass in the URL that we have in the geocodeUrl variable. There's no need to provide any other options, such as an option letting it know it's JSON. axios knows how to automatically parse our JSON data. What get returns is actually a promise, which means we can use ...