![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
sendgrid-send
Advanced tools
You don't need a library to use a REST API. Just create a valid JSON body, and make a POST request to SendGrid.
ESM
and CJS
- choose either import
or require
.0kb
- import a single-line JavaScript function.export const generateSgSendBody = (requestBody) => requestBody;
The requestBody
is typed according to the SendGrid API documentation.
Please reference the SendGrid API documentation for all supported values.
The generateSgSendRequest
function returns a Request object which can be used with the Fetch API. The URL, method, and HTTP headers are all set.
import { generateSgSendRequest } from 'sendgrid-send';
await fetch(
generateSgSendRequest(
{
from: { email: 'sender@doamin.com' },
personalizations: [{ to: [{ email: 'receiver@domain.com' }] }],
subject: 'SendGrid and the Fetch API is awesome.',
content: [{ type: 'text/plain', value: 'Best of both worlds.' }],
// ...
},
'<<YOUR_API_KEY_HERE>>'
)
);
npm i sendgrid-send
import { generateSgSendBody } from 'sendgrid-send';
// const { generateSgSendBody } = require('sendgrid-send');
const body = generateSgSendBody({
from: { email: 'sender@doamin.com' },
// ...
});
// Make a HTTP request using the method of your choice.
// e.g. node-fetch, cross-fetch, axios, got, undici
await fetch('https://api.sendgrid.com/v3/mail/send', {
method: 'POST',
headers: {
'Authorization': 'Bearer <<YOUR_API_KEY_HERE>>',
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
npm i sendgrid-send -D
import type { SendGridRequestBody } from 'sendgrid-send';
const body = {
from: { email: 'sender@doamin.com' },
// ...
} satisfies SendGridRequestBody;
Create a jsconfig.json
file and enable checkJs
.
{
"compilerOptions": {
"checkJs": true
}
}
@sendgrid/mail uses Axios - @sendgrid/client depends on it. ↩
FAQs
Generate JSON body for the SendGrid mail API
We found that sendgrid-send demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.