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>