brevo-node
brevo-node copied to clipboard
TypeError: Cannot read properties of undefined (reading 'AccountApi')
Hello,
I get error:
TypeError: Cannot read properties of undefined (reading 'AccountApi')
Why I am getting this error ?
import { ActionArgs, json } from "@remix-run/node";
import SibApiV3Sdk from '@getbrevo/brevo';
let apiInstance = new SibApiV3Sdk.AccountApi();
apiInstance.setApiKey(SibApiV3Sdk.AccountApiApiKeys.apiKey, 'xxxx')
export const action = async ({ request, params }: ActionArgs) => {
try {
const formData = await request.formData();
let c1 = new SibApiV3Sdk.ContactsApi();
const c2 = new SibApiV3Sdk.CreateContact();
c2.email = formData.get('email');
c2.listIds = [2];
const d = await c1.createContact(c2);
console.log(d);
} catch(e) {
console.log(e);
return json({err: 'err'});
}
};
You need to change your ES module import to:
import * as SibApiV3Sdk from "@getbrevo/brevo";
And you should no longer face this error.
Hello @pullmann4rent You can see our example here: https://github.com/getbrevo/brevo-node?tab=readme-ov-file#get-account-api-example I have updated it recently.