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

174
Vistas
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 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