If you use setDefaultRequest to change baseUrl to a custom value, and execute setDefaultRequest before setApiKey, the baseUrl that you thought you had changed to a custom value will be overwritten with SENDGRID_BASE_URL.
For example, if you want to send a request to a mock SendGrid prepared in a local environment, you need to be careful about the execution order of setApiKey and setDefaultRequest as follows.
// You must execute setApiKey first.
const client = new Client();
client.setApiKey('SG.xxxxx');
client.setDefaultRequest('baseUrl', 'localhost:3030');
In order to resolve it, I've decided to make the following changes, including setTwilioEmailAuth, which has a similar dependency:
Do not execute setDefaultRequest('baseUrl', SENDGRID_BASE_URL) inside setApiKey since the default value for baseUrl is SENDGRID_BASE_URL .
Execute setDefaultRequest('baseUrl', TWILIO_BASE_URL) inside setTwilioEmailAuth depending on whether baseUrl has been updated to a custom value.
Checklist
[x] I acknowledge that all my contributions will be made under the project's license
[x] I have made a material change to the repo (functionality, testing, spelling, grammar)
Fixes
If you use
setDefaultRequest
to changebaseUrl
to a custom value, and executesetDefaultRequest
beforesetApiKey
, thebaseUrl
that you thought you had changed to a custom value will be overwritten withSENDGRID_BASE_URL
.For example, if you want to send a request to a mock SendGrid prepared in a local environment, you need to be careful about the execution order of
setApiKey
andsetDefaultRequest
as follows.In order to resolve it, I've decided to make the following changes, including
setTwilioEmailAuth
, which has a similar dependency:setDefaultRequest('baseUrl', SENDGRID_BASE_URL)
insidesetApiKey
since the default value forbaseUrl
isSENDGRID_BASE_URL
.setDefaultRequest('baseUrl', TWILIO_BASE_URL)
insidesetTwilioEmailAuth
depending on whetherbaseUrl
has been updated to a custom value.Checklist
If you have questions, please file a support ticket.