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

Asynchnous transformer #90

Closed
fedulovivan opened this issue Jun 24, 2016 · 5 comments
Closed

Asynchnous transformer #90

fedulovivan opened this issue Jun 24, 2016 · 5 comments

Comments

@fedulovivan
Copy link

fedulovivan commented Jun 24, 2016

Hello, trying to work with redux-api using whatwg fetch polyfill as adapter.
The issue is that build-in transformer functionality provides synchronous interface.
When we deal with whatwg fetch, response body (json in my case) is being obtained via promise, so there is no elegant way to obtain it within transformer, modify and return in a transformed form.

transformer: data => {
  data.json().then(json=>{
     // here i need to make any transformations on json
     // ready im ready to provide results
 })  
}
@lexich
Copy link
Owner

lexich commented Jun 24, 2016

Transformer receive data, not promise. https://github.com/lexich/redux-api/blob/master/src/adapters/fetch.js If you want custom adapter for endpoint you should use

reduxApi({
endpoint: {
  url: "/api/endpoint",
  fetch(url, opts) {
    // return Promise with data, not Promise with Promise
  }
}
})

@fedulovivan
Copy link
Author

But when we using following suggested adapter:

function adapterFetch(url, options) {
  return fetch(url, options);
}

Transformer receives Response
How it could be transformed?

@lexich
Copy link
Owner

lexich commented Jun 24, 2016

It's wrong realization of adapter.

@fedulovivan
Copy link
Author

I think documentation should be corrected then. To avoid confusing of future users.

@lexich
Copy link
Owner

lexich commented Jun 27, 2016

Need to fix documentation.

@lexich lexich reopened this Jun 27, 2016
@lexich lexich closed this as completed Mar 30, 2017
@lexich lexich mentioned this issue Aug 10, 2017
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants