Add dcoumentation for API (#18)
This commit is contained in:
35
apps/docs/get-started/nodejs.mdx
Normal file
35
apps/docs/get-started/nodejs.mdx
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
title: NodeJS
|
||||
description: "Send your mail using unsend in NodeJS"
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Unsend API key](https://app.unsend.dev/api-keys)
|
||||
- [Verified domain](https://app.unsend.dev/domains)
|
||||
|
||||
## Code
|
||||
|
||||
```js server.ts
|
||||
const options = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer us_12345",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: {
|
||||
to: "jsmith@example.com",
|
||||
from: "jsmith@example.com",
|
||||
subject: "<string>",
|
||||
replyTo: "<string>",
|
||||
text: "<string>",
|
||||
html: "<string>",
|
||||
attachments: [{ filename: "<string>", content: "<string>" }],
|
||||
},
|
||||
};
|
||||
|
||||
fetch("https://app.unsend.dev/api/v1/emails", options)
|
||||
.then((response) => response.json())
|
||||
.then((response) => console.log(response))
|
||||
.catch((err) => console.error(err));
|
||||
```
|
Reference in New Issue
Block a user