Skip to content

Commit

Permalink
Merge pull request #147 from rasmusjp/fix/snazzymaps-cors
Browse files Browse the repository at this point in the history
Fix CORS issue with Snazzy Maps
  • Loading branch information
robertjf authored Jul 12, 2023
2 parents e01e8eb + b0b894b commit fc793a8
Showing 1 changed file with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular.module('umbraco.resources').factory('GMapsSnazzyMapsFactory',

function ($http, $q) {
function ($q) {

return {
GetMapStyles: function (apiKey, method, pageNumber) {
Expand All @@ -9,20 +9,18 @@
method = 'explore';
}

$http({
method: 'get',
url: 'https://snazzymaps.com/' + method + '.json?key=' + apiKey + '&page=' + pageNumber
}).then(
function success(response) {
deferred.resolve({
pagination: response.data.pagination,
styles: response.data.styles
});
},
function error(response) {
console.log(response, 'can not get data');
deferred.reject('can not get data')
});
fetch('https://snazzymaps.com/' + method + '.json?key=' + apiKey + '&page=' + pageNumber)
.then(response => response.json())
.then(data => {
deferred.resolve({
pagination: data.pagination,
styles: data.styles
});
})
.catch(error => {
console.log(error, 'can not get data');
deferred.reject('can not get data');
});
return deferred.promise;
}
};
Expand Down

0 comments on commit fc793a8

Please sign in to comment.