call createApi endpoints outside react components
rtk-q createApi endpoints can be called from outside react components
by dispatching the returned redux thunk from the endpoints’ .initiate().
Example from react forms.
| |
The redux store instance needs to be imported to .dispatch() the endpoint. The
response data will be added to the store and cached. More on
rtk query’s cache behavior
here.