Kimono labs API request

l have created an api with kimonolabs and am trying to make a request from that endpoint.
this doesnt seem to work…

.controller(‘maritimCtrl’, [’$scope’,’$http’, functio($scope, $http){
$http.get(‘http://www.kimonolabs.com/api/c7exfow8?apikey=xVEo5Biu1o3X3AFxId440GGc2WvoCrnk’).then(function(resp) {
console.log(‘Success’, resp);
console.log(resp.data);
}, function(err) {
console.error(‘ERR’, err);
})
}]);

any ideas

looks like your call to the kimono API is alright. but you have a typo in your angular controller definition:

.controller('maritimCtrl', ['$scope','$http', functio($scope, $http){

is missing the n at the end of function. should be:

.controller('maritimCtrl', ['$scope','$http', function($scope, $http){

.controller(‘maritimeCtrl’, [’$scope’,’$http’, function($scope, $http){
$http.get(‘http://www.kimonolabs.com/api/c7exfow8?apikey=xVEo5Biu1o3X3AFxId440GGc2WvoCrnk’).then(function(resp) {
console.log(‘Success’, resp);
console.log(resp.data);
}, function(err) {
console.error(‘ERR’, err);
})
}]);

am still getting an error!!!

XMLHttpRequest cannot load http://www.kimonolabs.com/api/c7exfow8?apikey=xVEo5Biu1o3X3AFxId440GGc2WvoCrnk. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access.

ERR Object {data: null, status: 0, config: Object, statusText: “”}

Ah, I see now, the problem is that you haven’t configured CORS support for your API. See how here:

Basically visit your api detail page and enter the domain you are making these calls from (e.g. mydomain.com):
https://www.kimonolabs.com/apis/c7exfow8#api

Basically because this is a front end call, the request is being made from some client somewhere. This request is going to be rejected (for security reasons) unless you specifically approve requests from clients on that domain. For local testing, the domain you’ll probably want is localhost.

If you don’t want to use CORS or cannot for some reason, then alternatively you can use JSONP to get around the security issue. Here’s an article from the AngularJS docs on how to do use JSONP:
https://docs.angularjs.org/api/ng/service/$http#jsonp

With JSONP you don’t need a CORS domain, it should work as is.

l have tried the localhost CORS DOMAIN but it still does not seem to work

what is the “Access-Control-Allow-Origin: {DOMAIN} response header” about?
l think this must help

l have got it using the jsonp method,thanks

.controller(‘maritimeCtrl’, [’$scope’,’$http’, function($scope, $http){
$http.jsonp(‘https://www.kimonolabs.com/api/4wfjeevq/?callback=JSON_CALLBACK’)
.success(function(resp) {
console.log(‘Success’, resp.results);
$scope.news = resp.results.MaritimeNews;
}, function(err) {
console.error(‘ERR’,err);
});
}])