Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

3.3K
Views
Error de tiempo de ejecución no controlado Error: no se pudo obtener + SWR + NEXT JS

Migré mi aplicación de reaccionar 17.02 para usar la última versión. recientemente de aquí .

Estoy tratando de usar rutas /api para obtener datos en el lado del cliente usando SWR .

lib/fetch

 export default async function fetcher(...args) { const res = await fetch(...args); if (!res.ok) throw new Error('Failed to fetch'); return res.json(); }

Esto está dentro de /pages/dashboard :

 const { data, error } = useSWR(process.env.APP_URL + '/api/user', fetcher, { suspense: true }); const router = useRouter(); useEffect(() => { setUser(data); console.log(series); }, [data, user]); if (error) { router.push('/404'); } return ( <Suspense fallback={<div>Loading...</div>}> <div className="h-screen max-w-7xl mx-auto px-4 bg-background-dark"> <Header title="Dashboard" /> <h1 className="text-5xl text-white">You will see all the series here</h1> </div> </Suspense> );

env.local

 APP_URL=http://localhost:3000

La aplicación intenta ir a esta url .

 http://localhost:3000/undefined/api/user

Error de tiempo de ejecución

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!