2
var users= $resource('http://myapp.herokuapp.com/users', {});
users.get();

After adding header method, http GET method change to OPTION

var users= $resource('http://myapp.herokuapp.com/users', {}, {
    get:{
        method:"GET",
        headers:{'x-access-token':'token'}
    }
});

users.get();

Please guide me why GET method change to OPTION Method.

1

2 Answers 2

1

Following REST conventions, an OPTION call is being made before the GET call.

To quote the spec:

This method allows the client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval.

Sign up to request clarification or add additional context in comments.

Comments

0

Preflight that causes confusion --> Preflight is an additional request the XHR object makes to make sure it's allowed to actually make the request

Check out https://remysharp.com/2011/04/21/getting-cors-working

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.