Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: console warning added when using an invalid API key #1077

Merged
merged 2 commits into from
Mar 30, 2020

Conversation

childish-sambino
Copy link
Contributor

Fixes #1068

@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Mar 30, 2020
this.defaultHeaders = {
'Accept': 'application/json',
Accept: 'application/json',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we convert to a non-string key here? Why only for the Accept key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quotes aren't needed here and is an eslint warning.

setApiKey(apiKey) {
this.apiKey = apiKey;

if (!this.isValidApiKey(apiKey)) {
console.warn(`API key does not start with ${API_KEY_PREFIX}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a spot to put the message: https://github.com/sendgrid/sendgrid-nodejs/blob/master/packages/helpers/constants/index.js -- nit: period at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's in the helpers package. I don't like defining the message in 1 package and using it in another.

packages/client/src/classes/client.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: code review request requesting a community code review or review from Twilio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error handling in setApiKey
2 participants