TypeError: Cannot read properties of undefined (reading 'TransactionalEmailsApi')
Closed this issue · 2 comments
Charlygraphy23 commented
import SibApiV3Sdk from 'sib-api-v3-typescript';
const apiInstance = new SibApiV3Sdk.TransactionalEmailsApi();
apiInstance.setApiKey(
SibApiV3Sdk.TransactionalEmailsApiApiKeys.apiKey,
process.env.SENDINBLUE_API_KEY
);
export const sendEmail = async (params: MAILParamsType) => {
let sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail();
sendSmtpEmail.subject = `My ${params.subject}`;
sendSmtpEmail.htmlContent = `<html><body>${params.body}</body></html>`;
sendSmtpEmail.sender = {
name: params.sender.name,
email: params.sender.email,
};
sendSmtpEmail.to = [{ email: params.to.email, name: params.to.name }];
return apiInstance.sendTransacEmail(sendSmtpEmail);
};
getting error :
const apiInstance = new SibApiV3Sdk.TransactionalEmailsApi();
^
TypeError: Cannot read properties of undefined (reading 'TransactionalEmailsApi')
at Object. (E:\Code\trello-clone-backend\src\config\emai.config.ts:16:37)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
Charlygraphy23 commented
This is working now by using import like this
import * as SibApiV3Sdk from 'sib-api-v3-typescript';
eakl commented
I had the same issue and this comment solved it
- import SibApi from '@sendinblue/client'
+ import * as SibApi from '@sendinblue/client'