本文介紹了如何消除axios中的控制臺錯誤?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
這是我的代碼:
async [types.GET_DATA]({commit, state}, data) {
try {
const res = await axios.post('/login', {
email: data.email,
password: data.password,
});
console.log(res)
} catch(e) {
if(e.response) {
console.log(e.response)
}
}
}
所以,每當用戶發送空字段時,我都會返回 400 Bad Request.axios 所做的是將錯誤與錯誤響應一起拋出.我需要做的是刪除該控制臺錯誤消息,只得到錯誤響應.
So, I return 400 Bad Request whenever user sends empty fields. What axios does is throws the error along with the error response. What I need to do is remove that console error message and only get the error response.
我該怎么做?
推薦答案
其實是不可能用JavaScript來做的.這是由于安全問題和腳本可能對用戶隱藏其活動.
It is actually impossible to do with JavaScript. This is due to security concerns and a potential for a script to hide its activity from the user.
您能做的最好的事情就是在您的控制臺中隱藏它們.
The best you can do is hide them from your console.
這篇關于如何消除axios中的控制臺錯誤?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!