1

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.

1

1 Answer 1

2

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);
    });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.