Skip to content

Commit

Permalink
Update: Added possibility to provide default request headers
Browse files Browse the repository at this point in the history
  • Loading branch information
laimonasr committed Jun 18, 2019
1 parent c3181f0 commit 3785bd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/models.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
interface IHeaders {
[header: string]: string;
}

interface IConfig {
baseUrl: string;
key: string;
Expand All @@ -6,6 +10,7 @@ interface IConfig {
password: string;
tokenRequest: any;
accessToken: string;
defaultHeaders: IHeaders;
}

export interface ITrustpilotApiConfig extends Partial<IConfig> {}
3 changes: 3 additions & 0 deletions src/request-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ export class RequestHelper {
constructor(private accessProvider: AccessProvider) {}

get basicRequest() {
const headers = this.accessProvider.trustpilotApiConfig.defaultHeaders || {};

return rp.defaults({
baseUrl: this.accessProvider.trustpilotApiConfig.baseUrl,
headers,
json: true,
});
}
Expand Down

0 comments on commit 3785bd3

Please sign in to comment.