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

348
Visualizações
API not fetching any response even for status 200 in react(Fetch API)

I am integrating an API with my react login form, but I am getting Failed to load response data: No data found for a resource with given identifier even for the status code 200.

When I fired the API in postman everything was working fine but when I integrate it with my application it is showing error index.js:1 Error: SyntaxError: Unexpected end of input

let userLogIn = async function() {
        fetch('http://kishansharma.pythonanywhere.com/login', {
            method: 'POST', 
            mode: 'no-cors', 
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded'
            },
            body: `email=${emailId}&password=${password}`,
        })
        .then(response => response.json())
        .then((data) => {
        console.log('Success:', data);
        })
        .catch((error) => {
        console.error('Error:', error);
        });
    }

I have added the code where I am integrating the API, any help will be appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The Error SyntaxError: Unexpected end of input usually comes from invalid json response. Maybe Postman shows you the raw response as text. You should check if the response is valid json with no syntax failurs.

Things to try:

  • In your headers object add the following: Accept': 'application/json'
  • Is the response realy valid JSON? Sometimes ther is a missing }
about 4 years ago · Juan Pablo Isaza Relatório
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