I'm making a put request using ReactJS, however, when I put in the wrong email/password combination, I get this logged on Chrome, even though I'm trying to catch all errors and show them in errorDiv
:
async connect(event) {
try {
const userObject = {
username: this.state.userName,
password: this.state.password
};
if (!userObject.username || !userObject.password) {
throw Error('The username/password is empty.');
}
let response = await fetch(('someurl.com'), {
method: "PUT",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(userObject)
});
let resJSON = await response.json();
if (!response.ok) {
throw Error(resJSON.message);
}
console.info(resJSON.message);
console.info(resJSON.message.auth_token);
window.location = "/ledger/home";
} catch (e) {
document.getElementById("errorDiv").style.display = 'block';
document.getElementById("errorDiv").innerHTML = e;
}
}