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

Error after upgrading to Astro 5 #1040

Closed
MrJonoCES opened this issue Dec 19, 2024 · 2 comments
Closed

Error after upgrading to Astro 5 #1040

MrJonoCES opened this issue Dec 19, 2024 · 2 comments
Assignees
Labels
cannot-reproduce [Issue] is not consistently reproducible

Comments

@MrJonoCES
Copy link

storyblok.com


Expected Behavior

import { useStoryblokApi } from "@storyblok/astro";

const baseData = (async () => {
  const storyblokApi = useStoryblokApi();
  try {
    const { data } = await storyblokApi.get("cdn/stories/site-data/site-data", {
      version: "published",
    });

    console.log("data", data);
    const content = data.story.content;
    return {
      title: content.title,
      description: content.Description,
      image: content.ogImage.filename,
      imageAlt: content.ogImage.alt,
      bio: content.bio,
    };
  } catch (error) {
    console.error("Error fetching site data:", error.message);
    console.error("Status:", error.status);
    console.error("Response:", error.response);
  }
})();

export { baseData };

This code was successfully return the story data before the upgrade

Current Behavior

Errors below are causing the build to fail

Error: storyblokApiInstance has not been initialized correctly
    at zn (.../NM/node_modules/@storyblok/astro/dist/storyblok-astro.es.js:1182:11)
    at eval (.../NM/src/data/siteData.js:7:65)
    at eval (...NM/src/data/siteData.js:35:3)

Steps to Reproduce

Installed the following packages

    "@storyblok/astro": "^5.1.0",
    "@storyblok/react": "^3.0.11",
    "astro": "^5.0.9",
@MrJonoCES MrJonoCES changed the title 'storyblokApiInstance has not been initialized correctly' error after upgrading to Astro 5 Error after upgrading to Astro 5 Dec 21, 2024
@dipankarmaikap dipankarmaikap added the cannot-reproduce [Issue] is not consistently reproducible label Dec 23, 2024
@dipankarmaikap dipankarmaikap self-assigned this Dec 23, 2024
@dipankarmaikap
Copy link
Contributor

@MrJonoCES Could you provide a minimal code example for me to test? I tried your code on the @storyblok/astro SDK with the package version you mentioned, along with your baseData code, and it seems to work fine.

However, I’d like to highlight that there’s currently a bug related to types in the latest SDK release. This issue will be fixed shortly—I’ve already created a PR for it.

Looking forward to your test case to investigate further!

@MrJonoCES
Copy link
Author

@dipankarmaikap thanks for your help. I went through the update process on a couple other sites using the exact same baseData setup and they work fine so I think the problem lies elsewhere. The only thing different in this project is that one component uses react but that's totally unrelated to this component. Back to the drawing board

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cannot-reproduce [Issue] is not consistently reproducible
Projects
None yet
Development

No branches or pull requests

2 participants