I have encountered an issue with setting up the configuration between Strapi and Next.JS. Despite configuring everything correctly in Strapi, I am unable to receive the API in Next.JS and display it on the screen. Instead, I keep getting an error message when trying to access the data.
When testing with Postman, both Get and Post requests work fine without any errors.
The error message I see in my browser is:
Server Error
Error: connect ECONNREFUSED ::1:1337
This error occurred while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown> (Error: connect ECONNREFUSED
: (1:1337)
TCPConnectWrap.afterConnect [as oncomplete]
node:net (1237:16)
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
wait - compiling...
event - compiled client and server successfully in 393 ms (125 modules)
wait - compiling / (client and server)...
wait - compiling...
event - compiled client and server successfully in 128 ms (144 modules)
wait - compiling /_error (client and server)...
wait - compiling...
event - compiled client and server successfully in 56 ms (145 modules)
error - Error: connect ECONNREFUSED ::1:1337
In my index.js file, I have set up a function to fetch data from the API endpoint 'http://localhost:1337/api/foods' using axios. However, the error persists and I am unable to display the fetched data on the webpage.
If anyone has encountered a similar issue or knows how to resolve this problem, please help me out. Your assistance would be greatly appreciated.