resend 6.31.0 → 6.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "6.31.0",
3
+ "version": "6.32.0",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
package/readme.md CHANGED
@@ -134,6 +134,47 @@ console.log(`Email ${data.id} with a React template has been sent`);
134
134
  >});
135
135
  >```
136
136
 
137
+ ## Request options
138
+
139
+ Every method takes request options as its last argument. Use `signal` to cancel a request or set a timeout, and `headers` to add request headers:
140
+
141
+ ```ts
142
+ const controller = new AbortController();
143
+ await resend.emails.send({ ... }, { signal: controller.signal });
144
+
145
+ // With a timeout (Node.js 18+) and a custom header
146
+ await resend.emails.list(
147
+ { limit: 50 },
148
+ { signal: AbortSignal.timeout(5000), headers: { 'X-Trace-Id': traceId } },
149
+ );
150
+ ```
151
+
152
+ An aborted request returns a network-failure error with a `null` status code. To tell a cancel apart from a real failure, check the status code and `signal.aborted`, and do not match on the error message:
153
+
154
+ ```ts
155
+ const signal = AbortSignal.timeout(5000);
156
+ const { error } = await resend.emails.list({}, { signal });
157
+
158
+ if (error?.statusCode === null && signal.aborted) {
159
+ // The request was cancelled or timed out.
160
+ }
161
+ ```
162
+
163
+ When a method has an optional argument before the request options, pass `undefined` in its place:
164
+
165
+ ```ts
166
+ await resend.broadcasts.send(broadcastId, undefined, { signal });
167
+ ```
168
+
169
+ A chained `publish()` sends a separate request, so it takes its own options:
170
+
171
+ ```ts
172
+ await resend.templates
173
+ .create({ name: 'welcome', html: '<p>Hi</p>' }, { signal })
174
+ .publish({ signal });
175
+ ```
176
+
137
177
  ## License
138
178
 
139
179
  MIT License
180
+