emberx-xml-http-request icon indicating copy to clipboard operation
emberx-xml-http-request copied to clipboard

how do you download using this?

Open NullVoxPopuli opened this issue 8 years ago • 5 comments

the examples only show upload

NullVoxPopuli avatar May 08 '16 12:05 NullVoxPopuli

Every request has an upload and download. I only showed uploads because usually that's higher latency, but you would construct a download in exactly the same way. You're right. The docs should be clearer about this.

cowboyd avatar May 08 '16 13:05 cowboyd

does a download still use PUT?

Is there a way to handle errors? (like 401?)

NullVoxPopuli avatar May 08 '16 14:05 NullVoxPopuli

It uses post by default, but will use whatever verb you bind to the method param. E.g. method="PUT"

All of the properties of the object are available. Including status (I think) the reader has all the properties available in each state.

Sent from my iPhone

On May 8, 2016, at 09:18, L. Preston Sego III [email protected] wrote:

does a download still use PUT?

Is there a way to handle errors? (like 401?)

— You are receiving this because you commented. Reply to this email directly or view it on GitHub

cowboyd avatar May 08 '16 23:05 cowboyd

So, I could set the method to GET for downloading. cool.

For errors, do I need to put an observer on the status property? or...? how does that work?

Like, ideally, I'd like to do something like this:

downloadFile().then(success => {}, error => {
  this.flashMessages.alert('whatever the error');
});

NullVoxPopuli avatar May 09 '16 00:05 NullVoxPopuli

Right now, this library is geared towards requests that you need to track in your templates, which for us, and as the ticket indicates, is primarily geared towards uploads. We should however add actions for all of the major XHR events.

cowboyd avatar May 09 '16 15:05 cowboyd