From 81569eb66eebdeff2abcddddab77b0db02cc23c2 Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Sun, 5 Feb 2023 20:30:07 +0000 Subject: [PATCH] Added some additional info about why users should use our fetch over the platform fetch --- apps/docs/functions/fetch.mdx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/docs/functions/fetch.mdx b/apps/docs/functions/fetch.mdx index 9b5804169..b671e4cf3 100644 --- a/apps/docs/functions/fetch.mdx +++ b/apps/docs/functions/fetch.mdx @@ -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.