Im卡住了!Vue.JS Axios POST请求。然后方法
我正在通过AXIOS从VUE应用向服务器发送POST请求。 一切正常,服务器响应。 问题是,.then方法永远不会被调用。那怎么可能? 奖励问题您如何处理VUE的请求?
非常感谢
methods:{
customMethod1: function() {
//AXIOS
var config = {
headers: {'My Custom Header 1': 'Header-Value'}
};
//POST request
axios.post('http://192.168.56.101:5000/post1', {name: 'Dave'}, config)
.then(function(response){
alert("posted successfully");
});
},
}
你可以显示完整的模块代码?也许,你不打电话给方法 –
谢谢你的答复基里尔。调用'customMethod1'方法。发布请求被执行并且服务器回复。只要'然后'黑色我什么都不能做。 – tr909
尝试添加一个'catch'回调,只是为了确保它没有失败。 – thanksd