dev server fails to load fetch
hbussell opened this issue · comments
Harley Bussell commented
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!