your next.js code is fine and the error that you have mentioned in the comment occurs when the Axios library is not able to communicate with the server due to Internet Connection issue, CORS policy etc.
I have tried running your code on my system and this is what I get in my console


I have tried running the API call using postman and it seemed to work properly. So reason 1 is ruled out and the only reason for your error is CORS as shown in the image.
I have also replaced your API call with mine and the code seems to work flawlessly. So be assured it's not an issue with nextjs or Axios.
Also Note that if you are willing to send cookies to the server that
has a domain different than the one your nextjs is running on then you
will be needed to add withCredentials: true in axios. Something like
this.
axios.get('url', {withCredentials: true});
Solution:
Allow your port (for example localhost:3000) on your server's allowed origin to access it.
header('Access-Control-Allow-Origin: *');
To enable CORS in PHP have a look at this solution:
Cross-Origin Request Headers(CORS) with PHP headers
Hopefully, this solves your problem. If it still doesn't then please do comment below.