Skip to content
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
Open
@st-h

Description

@st-h

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.

Metadata

Metadata

Assignees

Labels

BugIssue relates to a problem in the `ember-ajax` codebase

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions