Skip to content

Commit

Permalink
fix issue with new client overriding set api key (#1305)
Browse files Browse the repository at this point in the history
if you call `sgMail.setClient()` _before_ you call `sgMail.setApiKey()` then everything is great. If you call them in the order that this test does you'll forever get `Unauthorized` 401 section with data.headers not including `Bearer Authorization <<YOUR_API_KEY>>`
  • Loading branch information
seantcanavan authored Sep 29, 2021
1 parent 85b2c70 commit e1baddb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/typescript/mail.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Client } from "@sendgrid/client";
import sgMail = require("@sendgrid/mail");

// Test setApiKey() method
sgMail.setApiKey("MY_SENDGRID_API_KEY");

// Test setClient() method
sgMail.setClient(new Client());

// Test setApiKey() method
sgMail.setApiKey("MY_SENDGRID_API_KEY");

// Test setSubstitutionWrappers() method
sgMail.setSubstitutionWrappers("{{", "}}")

Expand Down Expand Up @@ -276,4 +276,4 @@ sgMail.send({
ipPoolName: 'sendgrid-ip-pool-name',
mailSettings: {},
trackingSettings: {},
});
});

0 comments on commit e1baddb

Please sign in to comment.