sendgrid-nodejs
sendgrid-nodejs copied to clipboard
Returning empty response body causes unexpected errors
The Mail Send v3 API supports JSON, but on a successful request the response body comes back empty, which is bad practice for JSON endpoints. What happens is:
const json = await response.json(); // <--- "SyntaxError: Unexpected end of JSON input"
JSON endpoints should, at a minimum, return a JSON-compatible response, even an empty string would prevent this unexpected error. See https://developer.mozilla.org/en-US/docs/Web/API/Response/json#return_value