Skip to content

Commit

Permalink
feat: added headers option to Api constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
bhovhannes committed Aug 10, 2017
1 parent 57a0916 commit f9d858d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/service/Api.js
Expand Up @@ -31,14 +31,26 @@ function Api(config) {
}

this.options = {};

if(config.headers) {
this.options.headers = {};
for (var key in config.headers) {
if (config.headers.hasOwnProperty(key)) {
this.options.headers[key] = config.headers[key];
}
}
}

if(config.apiKey) {
this.options.headers = {apiKey: config.apiKey};
this.options.headers = this.options.headers || {};
this.options.headers.apiKey = config.apiKey;
}

if(config.sessionId) {
this.options.headers = {sessionID: config.sessionId};
this.options.headers = this.options.headers || {};
this.options.headers.sessionID = config.sessionId;
}

this.options.url = config.host + path;
}

Expand Down

0 comments on commit f9d858d

Please sign in to comment.