This repository was archived by the owner on Jan 30, 2023. It is now read-only.
This repository was archived by the owner on Jan 30, 2023. It is now read-only.
non json response #321
Open
Description
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.