O Angular 1.6.3 não está permitindo uma solicitação JSONP permitida no 1.5.8
Angular1.6.3
não está permitindo uma solicitação permitida em1.5.8
e estou recebendo este erro:
$sce:insecurl
Processing of a Resource from Untrusted Source Blocked
O erro completo está disponívelaqui.
Gostaria de atualizar minha versão do angular para1.6.3
para obter o melhor e o mais recente, mas sou dependente dessa API. Existe uma maneira de marcar isso como uma API confiável ou outra maneira de usar essa API? Qual é a diferença entre essas duas versões que está causando isso?
Aqui está o código que estou tentando executar:
var app = angular.module('app', []);
app.controller('firstController', ['$http', function($http) {
console.log('firstController up and running');
var key = 'XXXXXXXXXXXXX'; // is an actual key
var self = this;
self.animal = {};
self.getRandomPet = function(){
var query = 'http://api.petfinder.com/'; // baseURL for API
query += 'pet.getRandom'; // selecting the method we would like to return
query += '?key=' + key; // Giving petfinder our key
query += '&format=json'; // Telling petfinder we want our response to be JSON
query += '&output=basic'; // Telling petfinder what data we want (more than just id)
var request = encodeURI(query) + '&callback=JSON_CALLBACK'; // removing spaces and special characters from response as well as making jsonp work with the callback
console.log('Request:', request);
$http.jsonp(request).then(function(response){
console.log(response);
self.animal = response.data.petfinder.pet;
});
}
self.getRandomPet();
}]);
Todo o repositório está disponível aqui:https://github.com/LukeSchlangen/angular-petfinder-api