Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

386
Vistas
Uncaught (in promise) SyntaxError: Unexpected end of input Node.js

I am making a component that should transfer the data in file controllers/hello.js(backend) to App.js(frontend in React.js app) which is imported from the router/collector components/hello.js

My components/hello.js looks like this:

import { React } from 'react'
import { useEffect, useState } from 'react';


export const Hello = ()=>{
    const[initialState, setInitialState] = useState([], )

    useEffect(()=> {
        fetch('http://localhost:3001/api/', {mode: "no-cors"})
            .then(response => response.json()).then(data => console.log(JSON.parse(data)))
    //         if (res.ok){
    //             return res.json()
    //     }
    //     }).then(jsonResponse => console.log(jsonResponse))
    },[])

    // console.log(initialState)
    console.log("should work ")
    return (<div>Hello</div>)
}

And I get this error:

        
       Uncaught (in promise) SyntaxError: Unexpected end of input
    at hello.js:9:1

when I check the API the only response I get is this enter image description here but it should be matching what's in localhost:3001/api/ or what's in controllers/hello.js which is enter image description here

Do you have any idea how I can solve this? Any help is appreciated.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda