After update to 2.x, ApiClient.instance is not defined anymore
Previously, a default API client could be used to only once set authentication data when using multiple endpoints:
const Brevo = require('@getbrevo/brevo');
const defaultClient = Brevo.ApiClient.instance;
defaultClient.authentications['api-key'].apiKey = apiKey;
const instance = new Brevo.TransactionalEmailsApi();
...
However, Brevo.ApiClient.instance is not defined anymore since the update to v2.x.
There is no documentation about the 1.x -> 2.x transition, which – I'm sorry to say – is absolutely horrible and frustrating developer experience.
Furthermore, it now does not seem to be necessary to wrap recipient addresses (!) in object instances anymore. So at least one can get rid of this ridiculous construction:
const sendSmtpEmail = new Brevo.SendSmtpEmail();
sendSmtpEmail.templateId = templateId;
- const to = new Brevo.SendSmtpEmailTo();
- to.email = email;
- sendSmtpEmail.to = [to];
+ sendSemtpEmail.to = [{ email }];
However I cannot seem to find any documentation about this transformation.
Hi @nicokaiser Sorry, the documentation was not updated since long, though it should have been. I understand your pain. Here I have updated the Readme.md with some examples, hope it helps: https://github.com/getbrevo/brevo-node?tab=readme-ov-file#we-have-two-options
Thanks for the update. I since replaced the SDK with a very simple HTTP call to the REST API. Since we only need one specific endpoint this vastly reduces the complexity and makes the project independent from SDK changes.