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>