Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

next js react app fetch not defined error

I am trying to clone the following next.js react app and run it on localhost:3000

https://github.com/elee-ittdublin/lab6-nextjs

when I open localhost:3000 I get the following error

Unhandled Rejection (ReferenceError): fetch is not defined Function._callee$ ./pages/index.js:22

20 | // see https://nextjs.org/learn/basics/fetching-data-for-pages
>22 | Index.getInitialProps = async function() {
24 |   const url = 'https://api.tvmaze.com/search/shows?q=batman';

I have tried to research what I am doing wrong but I still can not fix my problem. Can anyone see where I am going wrong?

Cheers

like image 326
Craig P H Avatar asked Oct 21 '25 14:10

Craig P H


1 Answers

If you go to the examples here examples and search for fetch, you will see what they are using. In the examples is node-fetch - node-fetch

like image 73
gdfgdfg Avatar answered Oct 23 '25 04:10

gdfgdfg