Skip to content

GET fails with 'android.os.NetworkOnMainThreadException' #111

Description

@chris-praxis

I'm testing on Android so I don't know about iOS.

Test code:

import * as HTTP from '@nativescript-community/https';
...
let url = "https://historylines.com/nexus/ttw.jsp?a=add&app=LA&uid=test_fde9f33899e13fcc&drill=Open%20Shooting%20-%20Single%20Target&shots=7";

console.log("logSession: "+url);

HTTP.request({
    url: url,
    method: "GET",
    timeout: 30000
})
.then((response) => {
    let content = response.content.toJSON();

    console.log("logSession response: "+JSON.stringify(content, null, 4));

    if(!content){
        console.error("logSession response is missing content");
        reject("logSession response is missing content");
    }else{
        resolve(content);
    }
})
.catch((err) => {
    console.error("logSession failed, "+err);
    reject(err);
});

When I run this code or similar with core/http, it succeeds. When I put the URL in a web browser, it succeeds. When I run with https, it fails with:

logSession failed, Error: android.os.NetworkOnMainThreadException

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions