Promise driver


This driver is useful when you want to work directly with promises. For instance, you could already have a ready to use library implementing communication with an API.


To install the package, just run:

npm install @redux-requests/promise

or you can just use CDN:


As for any driver, you must pass it to handleRequests:

import { createDriver } from '@redux-requests/promise';
driver: createDriver({
AbortController: window.AbortController,
processResponse: response => ({ data: response }),

AbortController is optional, by default it will use AbortController if available, with fallback to DummyAbortController which does nothing. If your environment doesn't support AbortController, you could pass a polyfill. If you don't, requests abort won't work.

processResponse is also optional, the default is response => ({ data: response }), it is useful if your promises resolve to more things than data, then you could for instance use response => ({ data: })

Once you have done that, you can use promises in request actions:

const fetchPhoto = id => ({
request: {
promise: axios.get(`${id}`),

Also note, that for mutations you need to pass meta.asMutation: true in your request actions, so the core library could know whether a request is a query or a mutation. For many drivers like axios, fetch and graphql it is not usually necessary as the library can deduct whether something is a query or a mutation by looking at request config, like GET request method will be typically a query while POST a mutation.

Last updated on by Konrad