NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
102 stars 50 forks source link

How can i receive JSON after successful or failed upload #38

Closed matart15 closed 7 years ago

matart15 commented 7 years ago

My Backend returns JSON with some info after upload. how can i get that.

Now i am getting

JS: eventTitle:complete {"_observers":{"progress":[{}],"error":[{}],"complete":[{}]},"disableNotifications":{},"_session":{"_id":"image-upload"},"_id":"image-upload{1}","_description":"asdfasdf","_upload":11910336,"_totalUpload":11910336,"_status":"complete”}

from e.object

    function onEvent(e) {
      console.log("----------------");
      console.log('Status: ' + e.eventName);
      console.log('Error: ' + e.error);

      // console.log(e.object);
      if (e.totalBytes !== undefined) {
        console.log('current bytes transfered: ' + e.currentBytes);
        console.log('Total bytes to transfer: ' + e.totalBytes);
      }
      console.log('eventTitle:' + e.eventName , JSON.stringify(e.object))

    }

 task.on("complete", onEvent);

my api should be returning this json.

{
  "meta": {
    "success": false,
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHA6XC9cL2FlMTM0Mmo0ODcuc21hcnRyZWxlYXNlLmpwXC9hcGlcL3Bvc3QiLCJpYXQiOjE0NzgxNDk3NTAsImV4cCI6MTQ3OTEwNTMyMywibmJmIjoxNDc4NTAwNTIzLCJqdGkiOiJiNDU3MTU2MzRiMTlmMGI4ZWU4YmRiNjBlMDQ5ZDFmNSJ9.9bmsddAeB_gFD-8V8JnPJeZYcvbn0n6XsHnIpfk1tjs",
    "error_message": "must upload video"
  }
}
davecoffin commented 7 years ago

See this issue: https://github.com/NativeScript/nativescript-background-http/issues/16