storyblok-react
storyblok-react copied to clipboard
Unable to get draft version
Describe the issue you're facing
My configuration is...
// the slug of the story
let slug = 'home';
// the storyblok params
let params = {
version: 'draft',
// appends the cache version to get the latest content
cv: Date.now(),
};
// checks if Next.js is in preview mode
if (context.preview) {
// loads the draft version
params.version = 'draft';
}
// loads the story from the Storyblok API
const storyblokApi = getStoryblokApi();
let { data } = await storyblokApi.get(
`cdn/stories/${slug}`,
params
);
Reproduction
https://staging.ziatile.com/
Steps to reproduce
No response
System Info
"@storyblok/js@^3.0.7":
version "3.0.7"
resolved "https://registry.yarnpkg.com/@storyblok/js/-/js-3.0.7.tgz#6c659c61be443cdb5c9cf1b368f4120f76d2769d"
integrity sha512-m6MpUhjEpDWMKftyjJhTkthd/I6LZ9xhuT/Wxa1e99Cf4niVC5jgMVPQ5tOsUgn3D8BKNL+6PI3hEj5dGKB9xw==
dependencies:
storyblok-js-client "^6.7.1"
Used Package Manager
yarn
Error logs (Optional)
No response
Validations
- [X] Follow our Code of Conduct
Hey @yujan01 ! Can you describe the issue a little more? Do you mean you're not able the fetch the draft version? Is it instead giving you the published version or older draft version.
We had a recent fix today, that might be related to this but it would be good to know some more details.
Also, while fetching you can pass custom cache parameter - https://github.com/storyblok/storyblok-js-client?tab=readme-ov-file#custom-fetch-parameter So for next js, it should look somewhat like this - https://github.com/storyblok/next.js-13-boilerplate/blob/main/app/page.js#L20 This can be useful too while working with Next js as the caches by url.