I am calling an API using Javascript:
fetch("/inquiries", {
method: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify(data),
})
.then(response => {
})
.catch(error => {
console.log(error);
});
When I submit invalid data I get an error which shows in console as:
If I access using a REST client I get:
How to get the error response as it shows on my Rest Client?
Update
I tried the following:
.then((response) => {
console.log(response);
console.log(response.error);
console.log(response.errors);
})
.catch((error) => {
});
And I got in the console:
If I check my network tab I see the response: