how to set custom headers with a $resource action?

headers for $resource is available since AngularJS 1.1.1. Make sure you have correct version used.

The format is

$resource('url/to/json', {}, {headers: { 'something': 'anything' }});

[edit by zuma]
The above doesn’t seem right. The third parameter to $resource should be a different. This seems more correct to me:

$resource('url/to/json', {}, {
    get: {
        method: 'GET',
        headers: { 'something': 'anything' }
    }
});

Leave a Comment