Skip to content

Commit

Permalink
override accept/content-type headers instead of adding. fixes #39 (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
HennerM authored and ghidoz committed Oct 20, 2016
1 parent dbbb34d commit 5c1f984
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/services/json-api-datastore.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,21 @@ export class JsonApiDatastore {
}

private getOptions(customHeaders?: Headers): RequestOptions {
let headers: Headers = this._headers ? this._headers : new Headers();
headers.append('Accept', 'application/vnd.api+json');
headers.append('Content-Type', 'application/vnd.api+json');
let requestHeaders = new Headers();
requestHeaders.set('Accept', 'application/vnd.api+json');
requestHeaders.set('Content-Type', 'application/vnd.api+json');
if (this._headers) {
this._headers.forEach((values, name) => {
requestHeaders.set(name, values);
})
}

if (customHeaders) {
customHeaders.forEach(function (values, name) {
headers.append(name, values[0]);
customHeaders.forEach((values, name) => {
requestHeaders.set(name, values);
});
}
return new RequestOptions({headers: headers});
return new RequestOptions({headers: requestHeaders});
}

private toQueryString(params: any) {
Expand Down

0 comments on commit 5c1f984

Please sign in to comment.