【发布时间】:2019-06-10 17:09:36
【问题描述】:
我正在使用 Nativescript-Vue 制作本机应用程序,在我的第一个组件中,我启动了一个简单的发布请求,该请求确实有效(我在桌面版本上对其进行了测试)。但是由于我忽略的原因,响应存在问题。我的回复显示请求已成功发送参数,但我得到一个状态:null 和一个数据:“”。你们中的一些人知道我该如何解决这个问题吗?
对于正在阅读本主题的任何人,感谢您抽出宝贵的时间,任何线索都将是可观的 :)
axios({
method: 'post',
url: url,
data: querystring.stringify({
grant_type: config.grant_type,
username: config.API_username,
password: config.API_password,
APIKeys: config.API_key
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
.then((response) => {
alert(JSON.stringify(response, null, 4));
})
.catch((error) => {
alert(JSON.stringify(error, null, 4));
});
【问题讨论】:
-
如果您不添加要发布的 URL 和/或 BE 代码,我们无法确定问题出在哪里。
-
感谢 Randy Casburn 的回复!好吧,没有什么特别的原因,我使用 axios 是因为我练习得最多,但是明天我将尝试使用 Nativescript 的 http Api 并且非常感谢您的建议 :) 对于 alert() 我知道这听起来很疯狂但我使用的是真实设备,所以我无法使用 console.log() 这就是我使用 alert() 进行调试的原因,也感谢您的第二个建议 :)
-
我把我的cmets做成答案的形式给你。
标签: javascript vuejs2 axios nativescript-vue