I've been trying to call an external API (Vimeo) from my AngularJS code, but all I get back is a 304 Not Modified. My code:
this.$scope.$safeApply(() => {
this.$http.jsonp('http://vimeo.com/api/v2/video/75532980.json?callback=?')
.success((r) => {
this.$log.info("Success: " + r);
})
.error((e) => {
this.$log.info("Error: " + e);
});
});
The odd thing is when I call the same URL from fiddler, everything seems ok and I get 200 response with the correct JSON.
Here is a working plunker: http://plnkr.co/edit/PZ7rQXb3guREqGFsodHX?p=preview
I took the answer from: AngularJS is caching JSONP by default
You add a timestamp to your query so it is not cached by angular. Also, I modified the value of your callback to JSON_CALLBACK as per doc (AngularJS $http).
Relative or absolute URL specifying the destination of the request. Should contain JSON_CALLBACK string.
$http.jsonp('http://vimeo.com/api/v2/video/75532980.json?callback=JSON_CALLBACK&_=' + (new Date().getTime()))
.success(function (r) {
$log.info("Success: " + r);
})
.error(function (e) {
$log.info("Error: " + e);
});