NativeScript Http Post Requests Blocked

风流意气都作罢 提交于 2019-12-08 03:43:33

问题


Trying to send a post request via https in Angular/Nativescript. I have tried post requests to our api as well as public apis and they all fail. In fact they don't fail because they don't show any errors, they just don't get executed at all.

These post requests work in the Angular web app, and they work using Postman. It seems to be a problem with Nativescript or Android permission issue.


回答1:


In apps targeting Android 9 or higher, the isCleartextTrafficPermitted() method returns false by default. If your app needs to enable cleartext for specific domains, you must explicitly set cleartextTrafficPermitted (android:usesCleartextTraffic="true") to true in your application tag in the AndroidManifest.xml located in your App_Resources directory




回答2:


It turns out the post request was working but I had a rxjs tap operator (useful in the web app) which caused an error in the subscription. Once I removed tap, the post request returned a valid response and valid observable.



来源:https://stackoverflow.com/questions/53251281/nativescript-http-post-requests-blocked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!