Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird task event data #271

Open
linesharina opened this issue Sep 9, 2020 · 2 comments
Open

Weird task event data #271

linesharina opened this issue Sep 9, 2020 · 2 comments

Comments

@linesharina
Copy link

TNS version: 6.7.4
tns-ios version: 6.5.2
nativescript-background-http version in package.json: "^4.2.1",

I'm testing on a physical iOS device, running iOS 13.

I have setup event listeners for "responded" and "complete"

task.on('responded', e => console.log(e));
task.on('complete', e => console.log(e));

I see that for the "responded" event I get responseCode -1 and the data property contains values from the server.
The "complete" event gets responseCode 200, however there is no data property in the event object.

I would like to check if the responseCode is 200 and then get the data inside either "responded" or "complete".

I can work around the "issue" by doing the following:

let data = null;
task.on("responded", (e) => (data = e.data));

task.on("complete", (e) => {
  if (e.responseCode == 200) {
    console.log("We have data", data);
  }
});

This seems a little weird to me, is it intended to work like this?

@kriefsacha
Copy link

Did you find more informations on that @linesharina ?

@phoenix503
Copy link

Yes, this is working fine @kriefsacha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants