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

175
Visualizações
React useEffect Api call with fetch gives SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data

I am using React with hooks to make a call to an open API. Somehow, the error keeps showing when I try to log the data to the console: "SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data". I'm not sure what's going wrong because postman is showing a perfectly fine object. Any help would be highly appreciated.

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

function App() {
  const [isLoading, setLoading] = useState(true)
  const [apb, setApb ] = useState([])
  useEffect(() => {
    fetch(
      'https://api.politie.nl/v4/vermist?language=nl&radius=5.0&maxnumberofitems=10&offset=0',
      {
        method: "get",
        mode: "no-cors",
        headers: new Headers({
          'Content-Type': 'application/json'
        }),
      }
    )
    .then(res => res.json())
    .then(response => {console.log(response)})
    .catch (error => {console.log(error)})
  },[]);
  return (
    <div className="App">
      <Header/>
      <SubMenu/>
      {isLoading ? <p>Loading</p> : <p>Loaded</p>}
    </div>
  );
}

export default App;
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

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