I am somewhat new to working with http promise objects.
I am using Angular JS to return json from an API http://www.asterank.com/api.
I have an angular controller making the call like so:
$http.jsonp('http://www.asterank.com/api/asterank?query={%22e%22:{%22$lt%22:0.1},%22i%22:{%22$lt%22:4},%22a%22:{%22$lt%22:1.5}}&limit=1&callback=JSON_CALLBACK').
success( function(data) {
console.log('great success');
}).error( function(r,t,et){
console.log(r);
console.log(t);
console.log(et);
});
When I check out Chrome's network monitor I see the response:
HTTP/1.1 200 OK
Date: Sun, 06 Oct 2013 19:06:26 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Server: gunicorn/18.0
Set-Cookie: session=eyJkaXNjb3Zlcl9maXJzdF90aW1lIjpmYWxzZX0.BTNGMg.eF89vHEeIpLH8sZiJOwCAJEjPhA; HttpOnly; Path=/
Content-Encoding: gzip
But I am seeing the error method fire, never the success :(
Is this simply because the server does not support JSONP? How do you access the data of these APIs if they don't support JSONP but they support JSON?
Found a nice solution:
Just in case anyone comes across this and like me am using EXPRESS, you create create a simple little API on your server using this:
https://npmjs.org/package/request
Here I don't need to spin up a whole proxy server, but you can request the JSON data from your server.