npm install --save redux-promise
`</pre>
<pre>`import promiseMiddleWare from 'redux-promise'
`</pre>
The default export is a middleware function. If it receives a promise, it will dispatch the resolved value of the promise.
It will not dispatch anything if the promise rejects.
If it receives an Flux Standard Action whose `payload` is a promise, it will either:
dispatch a copy of the action with the resolved value of the promise, and set
status
tosuccess
dispatch a copy of the action with the rejected value of the promise and set the
status
toerror
The middleware returns a promise to the caller so that it can wait for the operation to finish before continuing. This is especially useful for server-side rendering. If you find that a promise is not being returned, ensure that all middleware before it in the chain is also returning its
next()
call to the caller.Using in combination with redux-actions
Because it supports FSA actions, you can use redux-promise in combination with redux-actions
`createAction(`FETCH_DATA`, async id => { const result = await somePromise; return result.someValue });