-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No response from send function if attachment exists #1220
Comments
Hi @orassayag , |
Hi @JenniferMah,
Update: Hope you got it. |
@orassayag const fs = require('fs');
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey('SG.XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXXX-XXXXXXXXXXX');
const pathToAttachment = 'C:\\file.doc'; //absolute path to document
const attachment = fs.readFileSync(pathToAttachment).toString('base64');
const msg = {
to: '[email protected]',
from: '[email protected]',
subject: 'test',
text: 'test',
attachments: [
{
content: attachment,
filename: 'file.doc',
type: 'application/doc',
disposition: 'attachment'
},
],
};
(async () => {
try {
await sgMail.send(msg);
} catch (error) {
console.error(error);
if (error.response) {
console.log(typeof error.response.body)
}
}
})(); |
@orassayag |
Glad to help :) Don't really know what to do with "Pull requests and +1s on the issue summary will help it move up the backlog.", I'm just a simple developer who reports a bug :) If you need something else from me let me know. Thanks! |
Issue Summary
If I try to send an email with attachment added, I get not Promise resolve and no response, However, if I comment out the attachment logic, I receive error, like I expected.
Code not working:
Not getting any response, the code ignores the rest of any code that goes after the 'send' function.
Code working:
Code works as I expected, getting:
Unauthorized (401)
The provided authorization grant is invalid, expired, or revoked
null
null
result: null
Technical details:
"@sendgrid/mail": "^7.4.0"
The text was updated successfully, but these errors were encountered: