From d56e7aeaec9a5122cc5de18d35b1271fbf67ec1d Mon Sep 17 00:00:00 2001 From: Thiago Saife Rodrigues Date: Tue, 9 Jan 2024 13:08:44 -0300 Subject: [PATCH] feat(int-1031): Add support for custom Fetch parameter - Update README file. --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index a61675f0..74546c2d 100755 --- a/README.md +++ b/README.md @@ -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.