Added some additional info about why users should use our fetch over the platform fetch

This commit is contained in:
Eric Allam
2023-02-05 20:30:07 +00:00
parent 66d959282d
commit 81569eb66e
+9
View File
@@ -4,6 +4,15 @@ sidebarTitle: "Fetch"
description: "A generic fetch function that can be used to call any HTTP endpoint"
---
## Why use our fetch?
The `fetch` function provided by the trigger.dev SDK is a generic function that can be used to call any HTTP endpoint. It is designed to be used inside a `Trigger.run` function, and gives you the following benefits over using the standard [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) API:
- We automatically retry with exponential back off (this can be configured with the options param)
- The request and response are displayed in your Trigger.dev run dashbaord for easy debugging
- We automatically parse the response body as JSON and provide it as `body` on the response (and typed if you give provide a [responseSchema](/#response))
- We will retry the request reliably, even if your workflow is stopped, e.g. you deploy in the middle of a run. See [Resumability](/guides/resumability) for more information.
## Usage
A `fetch` function is available to use inside a `Trigger.run` function through the `context` argument, and should be familiar for anyone who has used the standard [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) API, with a few modifications.