Next.js Discord

Discord Forum

Unhandled Runtime Error: fetch failed

Unanswered
Bumble bee posted this in #help-forum
Open in Discord
Bumble beeOP
This is my code:

import City from '@/types/city'

export default async function CitiesList() {
  const cities = await (
    await fetch('http://localhost:8000/api/cities', {
      method: 'GET'
    })
  ).json()

  return (
    <>
      {cities.map((city: City) => (
        <>{city.name}</>
      ))}
    </>
  )
}


I get the response:
errno: -61,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '::1',
  port: 8000


I am quite helpless... 😦

5 Replies

what is running on port 8000?
Bumble beeOP
a Laravel API
try use 127.0.0.1?
Bumble beeOP
mmmh. cool. somehow using php artisan serve --host=127.0.0.1 works
please mark solution if your issue has been solved