Search code examples
sendgrid

Sendgrid Mail Send not returning a response (undefined)


I have been working with the sendgrid email API ("Mail Send") and I am trying to keep track of the mails that have been sent, so i can watch when they have been clicked or responded to. When I send a mail, I get a 202, but the response body is empty (not undefined or anything) According to the docs I am supposed to get a schema back. Am I missing some critical piece of information. I am testing with Ngrok

    email.send({ to: 'temikey@gmail.com',
    from: 'sam@market.io',
    subject: 'Hello world',
    text: 'Hello plain world!'
}).then(([response, body]) => {
    console.log('::::8', body) // EMPTY
    console.log(response.statusCode);
    console.log('::::4', response)

    }) .catch(error => {
    console.error('::::5', error.response?.body);
});

Solution

  • According to the docs you only get a response from the api call when there's an error. For a successful email send (with a 202 code) you shouldn't get any response.

    enter image description here