natemoo-re / microsite

Do more with less JavaScript. Microsite is a smarter, performance-obsessed static site generator powered by Preact and Snowpack.

Home Page:https://npm.im/microsite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dev server fails to load fetch

hbussell opened this issue · comments

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!

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

ezoic increase your site revenue