Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
242 views
in Technique[技术] by (71.8m points)

Nativescript - Https request not working on android platform v7.0.1

I′m completely lost on why this is happening, on previous versions everything worked well and on ios i don′t have any problems, but on android the below crashes:(i′m using the https module

https.request({
        url: "https://my_link",
        method: "POST",
        body:{ "grupo": gotData.tappedItem.grupo },
        allowLargeResponse:true,
        headers:{
            "Cache-Control": "no-cache",
            "Content-Type":"application/json"
        }
    }).then((response) => {

And this also crashes:

https.request({
        url: "https://my_link?grupo="+gotData.tappedItem.grupo,
        method: "GET",
        allowLargeResponse:true,
        headers:{
            "Cache-Control": "no-cache",
            "Content-Type":"application/json"
        }
    }).then((response) => {

Is it the code? am i typing anything wrong?. I already tried deleting the platforms and delete from the device, and i have download the certificate to app/assets folder but it just doesn′t work and this is the error:

System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onResponse failed
System.err: Error: android.os.NetworkOnMainThreadException
System.err: 
System.err: StackTrace:
System.err: onResponse(file: node_modules/nativescript-https/https.android.js:492:0)

My tns info:

? Getting NativeScript components versions information...
? Component nativescript has 7.1.2 version and is up to date.
? Component @nativescript/core has 7.1.4 version and is up to date.
? Component @nativescript/ios has 7.1.1 version and is up to date.
? Component @nativescript/android has 7.0.1 version and is up to date.
question from:https://stackoverflow.com/questions/65884325/nativescript-https-request-not-working-on-android-platform-v7-0-1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...