Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function unwrapAction(action: { type: string }) {
if (isFSA(action)) {
if (isError(action)) {
alert(action.payload!.message)
}
return action.payload
}
}
}
var sample1: Action = {
type: 'ADD_TODO',
payload: {
text: 'Do something.'
}
};
var sample2: ErrorAction = {
type: 'ADD_TODO',
payload: new Error(),
error: true
};
var result1: boolean = isError(sample1);
var result2: boolean = isFSA(sample1);
var result3: boolean = isError(sample2);
var result4: boolean = isFSA(sample2);
declare function alert (message: string): void
function unwrapAction(action: { type: string }) {
if (isFSA(action)) {
if (isError(action)) {
alert(action.payload!.message)
}
return action.payload
}
}
var result5: TextPayload = unwrapAction(sample1)
var sample1: Action = {
type: 'ADD_TODO',
payload: {
text: 'Do something.'
}
};
var sample2: ErrorAction = {
type: 'ADD_TODO',
payload: new Error(),
error: true
};
var result1: boolean = isError(sample1);
var result2: boolean = isFSA(sample1);
var result3: boolean = isError(sample2);
var result4: boolean = isFSA(sample2);
declare function alert (message: string): void
function unwrapAction(action: { type: string }) {
if (isFSA(action)) {
if (isError(action)) {
alert(action.payload!.message)
}
return action.payload
}
}
var result5: TextPayload = unwrapAction(sample1)
var result6: Error = unwrapAction(sample2)
const res = await asyncAwait;
returnedAction = dispatch({
...getResolveAction(),
...(isFSA(res) ? res : {
...(!!res && { payload: res }),
}),
});
if (isThunk(onResolve)) {
await onResolve(res, store);
}
} catch (e) {
returnedAction = dispatch({
...getResolveAction(true),
...(isError(e) ? e : {
...(!!e && { payload: e }),
}),
});
if (isThunk(onReject)) {
await onReject(e, store);
}
} finally {
return returnedAction;
}
};
};
return next => action => {
const shouldRedirect = isError(action) &&
(action.payload.status === 401);
if (shouldRedirect) {
next(action);
dispatch(removeAuthToken());
return dispatch(push(SIGNIN));
}
return next(action);
};
}