Answer the question
In order to leave comments, you need to log in
Get API with angularjs!?
Can't get json via angularjs
API https://api.privatbank.ua/api-info/exchangerate.html
var app = angular.module('spicyApp1', []);
app.controller('UserCtrl', ['$http', "$scope",
function($http, $scope) {
$http.jsonp("https://api.privatbank.ua/p24api/pubinfo?json&exchange&coursid=5").success(function(data) {
console.log(data);
});
}
]);
Answer the question
In order to leave comments, you need to log in
The API gives incorrect headers - "text/html", but you need "text/javascript".
Using $http.get and $http.post won't work because the API doesn't return "Access-Control-Allow-Origin" headers.
Therefore, write a request to the API in php (or whatever you use there) with the return of the result immediately to the output, and pull it through $http.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question