我有一个方法可以在单击按钮时调用登录终结点
login() {
let email = this.user.email
let password = this.user.password
axios.post('invalidRoute').then( (response) =>{
console.log('success')
console.log(response.data)
}).catch(function (error) {
console.log('error')
console.log(error)
})
},无论我将url路由设置为什么,axios都认为post是成功的,并且总是注销成功消息和空白响应数据。
我使用下面的代码行直接在组件的顶部导入axios
import axios from 'axios'我在其他地方不用它。
这是在一个基本的原生脚本vue js应用程序中。
这是我的main.js的样子
import Vue from "nativescript-vue";
import Vuex from 'vuex'
import store from './store/store';
import * as applicationSettings from 'tns-core-modules/application-settings'
import router from './router'
Vue.prototype.$router = router
Vue.config.silent = false
Vue.use(Vuex)
new Vue({
render: h => h('frame', [h(router['login'])]), store
}).$start()它快把我逼疯了,我不明白为什么它不能触发捕获物。
发布于 2019-02-05 04:41:46
我认为这是Axios的一个问题。当请求失败时,{N}状态代码将为null,当状态代码为False值时,Axios似乎将该请求视为成功。
看起来在他们的Github中有一个类似的issue。
发布于 2019-02-05 05:02:10
我发现axios和http在某些情况下都不调用任何东西。我不知道为什么,我被调查了两天。毫无头绪。只是使用了Fetch,现在一切都很好。
https://stackoverflow.com/questions/54522667
复制相似问题