How to use the redux-api-middleware/lib/util.actionWith function in redux-api-middleware

To help you get started, we’ve selected a few redux-api-middleware examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dremio / dremio-oss / dac / ui / src / mockApi / middleware.js View on Github external
error: true
        });
      }
    }

    // We can now dispatch the request FSA
    dispatch(requestType);

    // get fake response
    const res = getMockResponse(action);

    await sleep(1000);

    // Process the server response
    if (res.ok) {
      return next(await actionWith(
        successType,
        [action, getState(), res]
      ));
    }
    return next(await actionWith(
      {
        ...failureType,
        error: true
      },
      [action, getState(), res]
    ));
  };
}