Skip to content

Commit d322b42

Browse files
committed
Add snippet on webhooks
Signed-off-by: macdonst <simon.macdonald@gmail.com>
1 parent 8e14e87 commit d322b42

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: Webhooks
3+
---
4+
5+
A webhook is a method of augmenting or altering the behavior of a web page or web application with custom callbacks.
6+
7+
You can use a api route to receive webhooks from third parties:
8+
9+
<doc-code filename="app/api/webhook.mjs">
10+
11+
```javascript
12+
export async function post (req) {
13+
try {
14+
const data = req.body
15+
// Process the webhook payload
16+
// Validate payload, etc.
17+
} catch (error) {
18+
return {
19+
status: 400,
20+
}
21+
}
22+
23+
return {
24+
status: 200,
25+
}
26+
}
27+
```
28+
29+
</doc-code>

app/docs/nav-data.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const data = [
5959
path: '/docs/routing/api-routes/',
6060
label: 'API Routes',
6161
hasChildren: true,
62-
items: [ 'middleware', 'tutorial' ],
62+
items: [ 'middleware', 'tutorial', 'webhooks' ],
6363
},
6464
],
6565
},

0 commit comments

Comments
 (0)