Angular 1.6.3 no permite una solicitud JSONP que se permitió en 1.5.8
Angular1.6.3
no permite una solicitud que se permitió en1.5.8
y recibo este error:
$sce:insecurl
Processing of a Resource from Untrusted Source Blocked
El error completo está disponible.aquí.
Me gustaría actualizar mi versión de angular a1.6.3
para obtener lo último y lo mejor, pero yo dependo de esta API. ¿Hay alguna manera de marcar esto como una API confiable u otra forma de usar esta API? ¿Cuál es la diferencia entre estas dos versiones que está causando esto?
Aquí está el código que estoy tratando de ejecutar:
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();
}]);
El repositorio completo está disponible aquí:https://github.com/LukeSchlangen/angular-petfinder-api