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

dev server fails to load fetch #160

Closed
hbussell opened this issue Jun 20, 2021 · 1 comment
Closed

dev server fails to load fetch #160

hbussell opened this issue Jun 20, 2021 · 1 comment

Comments

@hbussell
Copy link

Using fetch function inside getStaticProps works fine running build but fails in dev server start.

yarn start
...
[microsite] ✔ Microsite started on http://localhost:8888

ReferenceError: fetch is not defined
    at getStaticProps (/src/pages/blog.js:14:17)
export default definePage(BlogPage, {
    path: '/blog',
    async getStaticProps(context) {
        const res = await fetch(`https://url`);
        const blogs = await res.json()
        return {
          props: {blogs}
        };
    },
});

Is there something simple i'm missing that is preventing the dev server from accessing fetch function?
I'm very new to snowpack so may have missed some thing that is assumed.

OS: macos mojave
Node version: v14.13.0

Potentially a similar issue to #132

Thanks!

@akellbl4
Copy link

It probably should be solved by this PR
I'm not sure if this project still in development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants