svrcekmichal / redux-axios-middleware

Redux middleware for fetching data with axios HTTP client
MIT License
920 stars 96 forks source link

Library limitations #67

Closed PeterKottas closed 7 years ago

PeterKottas commented 7 years ago

Hi. First of all, thanks for the effort that went into this. It's really a neatly done piece of code. Congrats!

Secondly, after using it for a little while, I seem to be starting to hit the limits of the api (maybe) and I was wondering if I am just doing something wrong, or if this is indeed not 100% suited for me.

My usecase: I have to fire a request and then on success I have a to chain a few more requests after that. e.g. :

  1. Create a resource.
  2. On success an id is returned
  3. Use this id to perform other requests

And here's where I struggle. Firing action in reducer is obviously an anti pattern so I can't go that way. Chaining of actions as described in readme would work (in my setup I don't get a promise for some reason so I am only speaking theoretically). The problem with this though is I can create this resource from many places . Chaining actions in UI seems therefore a bit too repetitive for comfort.

Am I missing something or would it make more sense for me to use pure axios with some defaults set? Main reason why I went with this lib is ease of adding authorization and very neat config on the action side. Wouldn't want to lose that but I feel like I might have hit a limitation.

Thanks for your input!

PeterKottas commented 7 years ago

It was indeed my misunderstanding of the lib capabilities. The dispatch itself returns a promise, therefore it's easy enough to chain these inside the action creator. Check out my #68 for implementation details