Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access ajax content before parsing #4136

Closed
sebyx07 opened this issue Feb 6, 2016 · 6 comments
Closed

access ajax content before parsing #4136

sebyx07 opened this issue Feb 6, 2016 · 6 comments

Comments

@sebyx07
Copy link

sebyx07 commented Feb 6, 2016

Is there a way to override how the store makes get/post request? i use base64 to compress the json and I need to inflate/deflate the content ?
Now I use plain ajax request and push the payload into the store

@bmac
Copy link
Member

bmac commented Feb 8, 2016

Hi @sebyx07. You can override the findAll, findRecord, updateRecord, createRecord methods on your Adapter to change how the ajax request is made. Also be sure to check out the Customizing Adapters guide for how to include a custom adapter in your app.

@sebyx07
Copy link
Author

sebyx07 commented Feb 8, 2016

i just override the ajax(), had to uncompress they payload
https://gist.github.com/sebyx07/306465253092f325337e
now the adapter works for other models too

@pangratz
Copy link
Member

Hey @sebyx07, I was just looking at your gist and if I am not mistaken, you don't need to overwrite the ajax method as a whole. If you overwrite handleResponse of the adapter, your compression should work:

export default DS.RESTAdapter.extend({
  handleResponse(status, headers, payload) {
    payload = uncompressToJSON(payload);

    return this._super(...arguments);
  }
}

In the gist you patched the parseResponseHeaders function too because of there was a bug when the header value contains a :. This has been fixed in #4137 so the patch isn't needed anymore.


Can you confirm that this works for you and close this issue if it does?

@pangratz
Copy link
Member

pangratz commented Mar 3, 2016

@sebyx07 can this issue be closed?

@sebyx07
Copy link
Author

sebyx07 commented Mar 3, 2016

yes, ty

@pangratz
Copy link
Member

pangratz commented Mar 3, 2016

👍

@pangratz pangratz closed this as completed Mar 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants