Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get draft version #1022

Open
1 task done
yujan01 opened this issue Mar 27, 2024 · 1 comment
Open
1 task done

Unable to get draft version #1022

yujan01 opened this issue Mar 27, 2024 · 1 comment
Labels
pending-author [Issue] Add Storyblok employee pending-triage [Issue] Add labels to describe it or prioritise it

Comments

@yujan01
Copy link

yujan01 commented Mar 27, 2024

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

@yujan01 yujan01 added pending-author [Issue] Add Storyblok employee pending-triage [Issue] Add labels to describe it or prioritise it labels Mar 27, 2024
@arorachakit
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-author [Issue] Add Storyblok employee pending-triage [Issue] Add labels to describe it or prioritise it
Projects
None yet
Development

No branches or pull requests

2 participants