Skip to content

Commit

Permalink
Add snippet on webhooks
Browse files Browse the repository at this point in the history
Signed-off-by: macdonst <[email protected]>
  • Loading branch information
macdonst committed Jul 23, 2024
1 parent 8e14e87 commit 16eaca3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions app/docs/md/routing/api-routes/webhooks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Webhooks
---

A webhook is a method of augmenting or altering the behavior of a web page or web application with custom callbacks.

You can use an API route to receive webhooks from third parties:

<doc-code filename="app/api/webhook.mjs">

```javascript
export async function post (req) {
try {
const data = req.body
// Process the webhook payload
// Validate payload, etc.
} catch (error) {
return {
status: 400,
}
}

return {
status: 200,
}
}
```

</doc-code>
2 changes: 1 addition & 1 deletion app/docs/nav-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const data = [
path: '/docs/routing/api-routes/',
label: 'API Routes',
hasChildren: true,
items: [ 'middleware', 'tutorial' ],
items: [ 'middleware', 'tutorial', 'webhooks' ],
},
],
},
Expand Down

0 comments on commit 16eaca3

Please sign in to comment.