Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Do not process actions without a [RSAA] property
if (!isMockRSAA(action)) {
return next(action);
}
// Try to dispatch an error request FSA for invalid RSAAs
const validationErrors = validateMockRSAA(action);
if (validationErrors.length) {
throw validationErrors;
}
// Parse the validated RSAA action
const callAPI = action[CALL_MOCK_API];
let { endpoint, headers } = callAPI;
const { bailout, types } = callAPI;
const [requestType, successType, failureType] = normalizeTypeDescriptors(types);
// Should we bail out?
try {
if ((typeof bailout === 'boolean' && bailout) ||
(typeof bailout === 'function' && bailout(getState()))) {
return;
}
} catch (e) {
return next({
...requestType,
payload: new RequestError('[RSAA].bailout function failed'),
error: true
});
}
// Process [RSAA].endpoint function