axiosでエラー時にもthenが実行されちゃう【備忘録】
環境
react: v18.2.0
axios: v1.5.0
該当のコード
axios.get("url", data)
.catch((e) => {
console.log(e);
})
.then((res) => {
console.log(res);
});解決
よくよく考えると当たり前だが、catchとthenの順番が逆だった
axios.get("url", data)
.then((res) => {
console.log(res);
});
.catch((e) => {
console.log(e);
})