Skip to content

Commit

Permalink
fix(docs): Add Fetch action documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTolmay committed Oct 4, 2023
1 parent f075afc commit 8a2af0c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
47 changes: 44 additions & 3 deletions packages/docs/actions/Fetch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,48 @@ _ref:
vars:
pageId: Fetch
pageTitle: Fetch
filePath: actions/Fetch.yaml
types: ''
types: |
```
(params: {
url: string,
options: object,
responseFunction: string
}): string | object
```
description: |
##### TODO: This page needs to be updated.
The `Fetch` implements the [fetch web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch) and can be used to make HTTP requests directly from the web client.
params: |
###### object
- `url: string`: __Required__ - The URL of the resource you want to fetch..
- `options: object`: The options object of the `fetch` global function. These include, but are not limited to:
- `method: string`: The request method, e.g., `"GET"`, `"POST"`. The default is `"GET"`.
- `headers: object`: An object with headers to add to the request.
- `body: string`: The request body. Use the [`_json.stringify`](/_json) operator to create a JSON body.
- `responseFunction: enum`: If the `responseFunction` is specified, that function will be executed on the returned Response object. If specified this is equavalent to `await fetch(url, options).json()`. Should be one of of `'json'`, `'text'`, `'blob'`, `'arrayBuffer'`, or `'formData'`.
examples: |
###### Call a JSON API endpoint:
```yaml
- id: fetch
type: Fetch
params:
url: https://example.com/api/products
options:
method: GET
responseFunction: json
```
###### Make a post request:
```yaml
- id: fetch
type: Fetch
params:
url: https://example.com/api/products/abc
options:
method: POST
headers:
Content-Type: application/json
body:
_json.stringify:
- _state: product
responseFunction: json
```
10 changes: 0 additions & 10 deletions packages/docs/templates/actions.yaml.njk
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ _ref:
_var: pageTitle
section: Actions
content:
- id: warning
type: Alert
visible:
_not:
_not:
_var: warning
properties:
message:
_var: warning
type: warning
- id: types
type: Markdown
style:
Expand Down

0 comments on commit 8a2af0c

Please sign in to comment.