NextJS - ky-universal error - Cannot use import statement outside a module

Viewed 698

I am trying to use ky-universal in a NextJS project however just using the library gives this error:

import fetch, {Headers, Request, Response} from 'node-fetch';
^^^^^^

SyntaxError: Cannot use import statement outside a module

I am just making a test request in a useEffect hook:

useEffect(() => {
  const response = ky.get('https://test.com');
  console.log(response);
});

I'm going around in circle and can't get this to work. Any suggestions? Thank you!

0 Answers
Related