微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

axios返回空数据和空状态

如何解决axios返回空数据和空状态

我使用nativescript-vue和axios开发了一个应用程序。我正在使用来自android studio的android模拟器。 因此我的应用程序上周运行正常,因为我们进行了此检查。现在,我想对此应用程序进行更新,但是当我尝试登录时,它返回空的result.data和空的result.status

我尝试在Postman中检查它,以查看错误是否在api中,但其工作正常:

enter image description here

我还安慰了用户登录详细信息:

enter image description here

这是控制台axios的结果:

enter image description here

这是我的方法

enter image description here

感谢任何帮助我指出正确方向的帮助。谢谢。

解决方法

如果您正在等待axios调用,请使用以下语法:

const response = await axios.post({ method:POST,url:'someUrl',data:'somedata' },newPost);

,然后记录响应变量以查看是否有效。

,

我也面临这个问题,添加

android:usesCleartextTraffic="true"

我的AndroidManifest.xml解决了这个问题。

 <application
        android:usesCleartextTraffic="true"
        android:name="com.tns.NativeScriptApplication"
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
....
<application>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。