Closed Nate-Huerd closed 2 years ago
First, get lat and lng from Best Buy API. Take nearest 5 stores data and send that data to the request to Bing Maps.
var getLoc = function() {
var bestbuyapiUrl = "https://api.bestbuy.com/v1/stores(area(55423,50))?show=storeId,storeType,lat,lng,distance&apiKey=" + bestbuyApiKey;
//want to only return where storeType = Big Box and send zip in place of 55423, once ready.
fetch(bestbuyapiUrl)
.then(function(response) {
if (response.ok) {
console.log(response);
response.json().then(function(data) {
//use closest 5 stores storeData(storeId, storeType, lat, lng, distance);
console.log(data);
//what to do with these variables
//var lat = data.store[1].lat;
//var lng = data.store[1].lng;
});
} else {
//modal ("Error: " + response.statusText);
}
});
};
var setLoc = function() {
//set this variable on under var bestbuyApiKey
//var bingmapApiKey = "AlhvFsP11Bn7teegeVUFvdrw312hORJoNPDjnSGs5qZk5S9lwrAspUQw5wk9wi9I";
var bingapiUrl = "http://dev.virtualearth.net/REST/v1/Locations/" + lat + "," + lng + "?&key=" + bingmapApiKey;
fetch(bingapiUrl)
.then(function(response) {
if (response.ok) {
console.log(response);
response.json().then(function(data) {
locationData(geocodePoints.coordinates, data);
console.log(data);
//coordinates are do not have their own field/id
//var coordinates = data.geocodePoints[1].coordinates;
});
} else {
//modal ("Error: " + response.statusText);
}
});
};
Loop through the response and only bring in the Best Buy stores.