Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

387
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda