Skip to content

Commit

Permalink
Update client.js
Browse files Browse the repository at this point in the history
  • Loading branch information
shrutiburman committed Nov 23, 2023
1 parent 4dee264 commit b69670e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/client/src/classes/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Client {
constructor() {
this.auth = '';
this.impersonateSubuser = '';
this.sendgrid_region = '';

this.defaultHeaders = {
Accept: 'application/json',
Expand All @@ -43,10 +44,10 @@ class Client {

setApiKey(apiKey) {
this.auth = 'Bearer ' + apiKey;
console.log('baseUrl: ');
console.log(this.request.baseUrl);
this.setDefaultRequest('baseUrl', SENDGRID_BASE_URL);

// this means that region based setter was not called
if (this.sendgrid_region == '') {
this.setDefaultRequest('baseUrl', SENDGRID_BASE_URL);
}
if (!this.isValidApiKey(apiKey)) {
console.warn(`API key does not start with "${API_KEY_PREFIX}".`);
}
Expand Down Expand Up @@ -110,6 +111,7 @@ class Client {
if (!REGION_HOST_MAP.hasOwnProperty(region)) {
console.warn('Region can only be "global" or "eu".');
} else {
this.sendgrid_region = region;
this.setDefaultRequest('baseUrl', REGION_HOST_MAP[region]);
}
return this;
Expand Down

0 comments on commit b69670e

Please sign in to comment.