I am trying to Catch an Error of my Fetch Function.
ive tried to catch my function with this:
updateState() {
fetch('http://127.0.0.1:3333/xxx')
.then((res) => res.json())
.then((json) => {
this.setState(() => {
return {
lightState: json.value
}
});
}
).catch(function () {
console.log("error");
});
}
but i still get the Errormessage in the console
PS: In the Console i also get the "error" from the catch function. But the ERR_CONNECTION_REFUSED error still comes up