Hi there, we've just started using the brevo-node client for sending transactional emails in our web app and encountered an unexpected behavior in the sendTransacEmail function
|
body: ObjectSerializer.serialize(sendSmtpEmail, "SendSmtpEmail") |
where it throws an error when the
cc field of the
sendSmtpEmail parameter is an empty array.
It took us some time to debug the issue and make this fix where we must explicitly pass cc: false or cc: undefined instead of cc: [].
Before:
const cc: TEmail[] = [];
if (otherUser.isActive) {
cc.push({ email: otherUser.email });
}
...
return {
to: [{ email: recipientUserEmail }],
cc,
};
After:
...
return {
to: [{ email: recipientUserEmail }],
...(cc.length > 0 && { cc }), // the fix
};
This is a strange behavior to have since the typescript type specify that cc is an array. We think you should allow an empty array to be passed so what happened to us today doesn't happen to others in the future.
Merci!
Hi there, we've just started using the brevo-node client for sending transactional emails in our web app and encountered an unexpected behavior in the
sendTransacEmailfunctionbrevo-node/api/transactionalEmailsApi.ts
Line 1686 in d4dd685
ccfield of thesendSmtpEmailparameter is an empty array.It took us some time to debug the issue and make this fix where we must explicitly pass
cc: falseorcc: undefinedinstead ofcc: [].Before:
After:
This is a strange behavior to have since the typescript type specify that
ccis an array. We think you should allow an empty array to be passed so what happened to us today doesn't happen to others in the future.Merci!