You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
Is there a nice way to handle non json responses, like binary data or an empty response body?
As for binary data, tampering with the underlying xhr works, but hasn't been quite easy to figure out as one first needs to be aware of if it is an issue with the addon itself or a jquery configuration/issue.
this.get('ajax').raw('/binary-resource', {
dataType: "binary",
xhr: () => {
let myXhr = $.ajaxSettings.xhr();
myXhr.responseType='arraybuffer'
return myXhr;
}
}).then(({ arrayBuffer }) => {
// all good
})
Might save people some work by mentioning in the docs, if there isn't an easier way. However, it might be nice to just try to parse json if the content type actually indicates a json response.
The text was updated successfully, but these errors were encountered:
@alexlafroscia sorry, not at the moment. Had been trying to avoid putting more jquery into projects anyways, so probably I'll go with plain xhrs in the end. But didn't even had the time to check that so far.
I wish it were that simple. If you want to do things like show progress to your users, fetch related stuff is out 😞 And I noticed that if you want to do things like that with jquery you find yourself digging around in plain xhr stuff again. So, when I can find the time I want to promisify xhr2 and see how that ends up.
Is there a nice way to handle non json responses, like binary data or an empty response body?
As for binary data, tampering with the underlying xhr works, but hasn't been quite easy to figure out as one first needs to be aware of if it is an issue with the addon itself or a jquery configuration/issue.
Might save people some work by mentioning in the docs, if there isn't an easier way. However, it might be nice to just try to parse json if the content type actually indicates a json response.
The text was updated successfully, but these errors were encountered: