sendgrid / sendgrid-nodejs

The Official Twilio SendGrid Led, Community Driven Node.js API Library
https://sendgrid.com
MIT License
3k stars 782 forks source link

(intermediate value) is not iterable #1408

Open NakileSolutions opened 3 months ago

NakileSolutions commented 3 months ago

Hello,

I'm trying to instantiate multiple client instances manually as written in your README.me but when I try to use the request function I have this error: TypeError: (intermediate value) is not iterable

You can have a look at my code here :

import { Client } from "@sendgrid/client";
import sgMail from "@sendgrid/mail";
import { config } from "../../config";

const sgClient = new Client();
const sgClient2 = new Client();

sgClient.setApiKey(config.apiKey);
sgClient2.setApiKey(config.apiKey2);

export { sgClient, sgClient2, sgMail };
const sendgrid = priority ? sgClient2 : sgClient;
    // eslint-disable-next-line no-await-in-loop
    const [res, body]: [ClientResponse, TemplateResponseBody] = await sendgrid.request({
      method: "GET",
      url,
    });