Skip to content

Commit f56b544

Browse files
authored
Update context.call parameter documentation (#338)
1 parent e4cd7f1 commit f56b544

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

workflow/basics/context.mdx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ export const { POST } = serve<{ topic: string }>(async (context) => {
184184
})
185185
```
186186

187+
context.call parameters are:
188+
- `url`: The URL to send the HTTP request to.
189+
- `method`: The HTTP method to use for the request (e.g., GET, POST, PUT, etc.). Defaults to GET.
190+
- `body`: Body to use in the request
191+
- `headers`: An object representing the HTTP headers to include in the request.
192+
- `retries`: The number of retry attempts to make if the request fails. [Retries use exponential backoff](https://upstash.com/docs/qstash/features/retry). Defaults to 0 (no retries).
193+
- `timeout`: The maximum duration to wait for a response from the endpoint, in seconds. If retries are enabled, this timeout applies individually to each retry attempt.
194+
187195
context.call attempts to parse the response body as JSON. If this is not possible, the body is returned as it is.
188196

189197
In TypeScript, you can declare the expected result type as follows:
@@ -197,15 +205,6 @@ type ResultType = {
197205
const result = await context.call<ResultType>( ... );
198206
```
199207

200-
By default, `context.call` only calls the given URL once. If you wish to add retries, you can do so with the `retries` option:
201-
202-
```ts
203-
await context.call("call", {
204-
url: ...,
205-
retries: 3
206-
})
207-
```
208-
209208
<Note>
210209
The context.call method can make requests to any public API endpoint. However, it cannot:
211210

0 commit comments

Comments
 (0)