Search⌘ K

Normalizing Responses

Explore how to use the normalizr library in Redux to automatically normalize nested API responses. Understand how to dispatch multiple actions from a single response and implement middleware to handle arrays of actions for better state management.

We'll cover the following...

When we use the normalizr library in Redux, the API middleware can automatically apply the normalization on the received data:

import { normalize } from 'normalizr';

const {
  url,
  onSuccess,
  onFailure,
  method = 'GET',
  data,
  transformRequest,
  transformResponse,
  schema
} = action.payload;

const dataProperty = ['GET', 'DELETE'].includes(method) ? 'params' :
...