Skip to content

TypeError: Cannot read properties of undefined (reading 'merge') #3567

@karanshah229

Description

@karanshah229

Getting this error on Next.js project:

image

Code for the rtkQueryErrorLogger:

import { isRejectedWithValue } from '@reduxjs/toolkit';

import { logger } from 'src/utils/logger';

import type { Middleware, MiddlewareAPI } from '@reduxjs/toolkit';

export const rtkQueryErrorLogger: Middleware = (_api: MiddlewareAPI) => (next) => (action) => {
  if (isRejectedWithValue(action)) {
    logger.error({
      message: `Error in API call ${action?.meta?.baseQueryMeta?.request?.url}`,
      error: action,
    });
  }

  return next(action);
};

Stuck on this for a while, any help is appreciated.

cc: @phryneas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions