如何消除axios中的控制台错误?
- 作者: 我是段花花花花花花
- 来源: 51数据库
- 2022-12-20
问题描述
这是我的代码:
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.
推荐阅读
热点文章
检查拆分键盘
0
带有“上一个"的工具栏和“下一个"用于键盘输入AccessoryView
0
Activity 启动时显示软键盘
0
UIWebView 键盘 - 摆脱“上一个/下一个/完成"酒吧
0
在 iOS7 中边缘滑动时,使键盘与 UIView 同步动画
0
我的 iOS 应用程序中的键盘在 iPhone 6 上太高了.如何在 XCode 中调整键盘的分辨率?
0
android:inputType="textEmailAddress";- '@' 键和 '.com' 键?
0
禁用 iPhone 中键盘的方向
0
Android 2.3 模拟器上的印地语键盘问题
0
keyDown 没有被调用
0
