Skip to content

Custom headers

Michael Dostál edited this page Nov 14, 2018 · 1 revision

By default, the library adds these headers, according to the JSON API MIME Types:

Accept: application/vnd.api+json
Content-Type: application/vnd.api+json

You can also add your custom headers to be appended to each http call:

this.datastore.headers = new Headers({'Authorization': 'Bearer ' + accessToken});

Or you can pass the headers as last argument of any datastore call method:

this.datastore.findAll(Post, {
    include: 'comments'
}, new Headers({'Authorization': 'Bearer ' + accessToken}));

and in the save() method:

post.save({}, new Headers({'Authorization': 'Bearer ' + accessToken})).subscribe();
Clone this wiki locally