100
rated 0 times
[
107]
[
7]
/ answers: 1 / hits: 9469
/ 4 Years ago, thu, may 7, 2020, 12:00:00
Imagine in my app I have:
let res = await axios({
url: 'https://test.com/posts/1',
method: 'get',
timeout: 8000,
headers: {
'Content-Type': 'application/json',
}
})
console.log("Success");
So you can see that I don't manually check the response status code of above call, rather assume that if "Success"
was printed on console, the above call was success, otherwise there would be an exception or promise rejection and JS wouldn't continue till console.log
.
Is this safe assumption?
More From » axios