To use this middleware with Redux Actions, return a promise from the payload creator. Note this example is experimental and not tested; it may not work as expected.
1
// Create an async action
2
const fooAction =createAction('FOO',async()=>{
3
const{ response }=awaitasyncFoo();
4
return response;
5
});
6
​
7
// Use async action
8
fooAction('123')
Copied!
This would dispatch FOO_PENDING and FOO_FULFILLED with the data as the payload.