I'm playing with JSON and API calls for the first time in javascript - specifically using the What3Words convert to co-ordinates API.
I understand the basic tutorial as far as using a 3 word search to return a location as an object using the following code:
what3words.api.convertToCoordinates("shield.mats.windy").then(function (response) {
console.log("[convertToCoordinates]", response);
});
the returning JSON looks like this:
{
"country": "GB",
"square": {
"southwest": {
"lng": -0.119971,
"lat": 51.517491
},
"northeast": {
"lng": -0.119927,
"lat": 51.517518
}
},
"nearestPlace": "Clerkenwell, London",
"coordinates": {
"lng": -0.119949,
"lat": 51.517505
},
"words": "shield.mats.windy",
"language": "en",
"map": "https://w3w.co/shield.mats.windy"
}
How might I then programmatically parse the co-ordinates object from this to return as a string and display on the HTML file, for example?