Skip to content

Commit

Permalink
feat(int-1031): Add support for custom Fetch parameter
Browse files Browse the repository at this point in the history
- Update README file.
  • Loading branch information
Thiago Saife Rodrigues committed Jan 9, 2024
1 parent 3e1e5bb commit d56e7ae
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,36 @@ window.storyblok.on('input', (event) => {
})
```

### Custom Fetch parameter

You can now pass an aditional paramater to the following calls: `get`, `getAll`, `post`, `put`, `delete`, `getStory` and `getStories`. This parameter is optional and it is the same as the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request) parameter.

**Example**

```javascript
const data = {
story: {
name: 'xy',
slug: 'xy',
},
}

Storyblok.get('cdn/stories/home', {
version: 'draft',
{
mode: 'cors',
cache: 'no-cache',
body: JSON.stringify(data),
}
})
.then((response) => {
console.log(response)
})
.catch((error) => {
console.error(error)
})
```

### Method `Storyblok#get`

With this method you can get single or multiple items. The multiple items are paginated and you will receive 25 items per page by default. If you want to get all items at once use the `getAll` method.
Expand Down

0 comments on commit d56e7ae

Please sign in to comment.