Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default () => next => action => {
// If not a promise, continue on
if (!isPromise(action.payload)) {
return next(action);
}
/**
*
* The error middleware serves to dispatch the initial pending promise to
* the promise middleware, but adds a `catch`.
* It need not run in production
* process.env.NODE_ENV === 'development'
*/
if (true) {
// Dispatch initial pending promise, but catch any errors
return next(action).catch(error => {
console.error(`${action.type} caught at middleware with reason: ${JSON.stringify(error.message)}.`);
if (error && error.response && error.response.data) {
const message = getErrorMessage(error.response.data);
export default () => next => action => {
// If not a promise, continue on
if (!isPromise(action.payload)) {
return next(action);
}
/**
*
* The error middleware serves to dispatch the initial pending promise to
* the promise middleware, but adds a `catch`.
* It need not run in production
*/
if (process.env.NODE_ENV === 'development') {
// Dispatch initial pending promise, but catch any errors
return next(action).catch(error => {
console.error(`${action.type} caught at middleware with reason: ${JSON.stringify(error.message)}.`);
if (error && error.response && error.response.data) {
const message = getErrorMessage(error.response.data);
console.error(`Actual cause: ${message}`);
export default () => next => action => {
// If not a promise, continue on
if (!isPromise(action.payload)) {
return next(action);
}
/**
*
* The error middleware serves to dispatch the initial pending promise to
* the promise middleware, but adds a `catch`.
* It need not run in production
*/
if (process.env.NODE_ENV === 'development') {
// Dispatch initial pending promise, but catch any errors
return next(action).catch(error => {
console.error(`${action.type} caught at middleware with reason: ${JSON.stringify(error.message)}.`);
if (error && error.response && error.response.data) {
const message = getErrorMessage(error.response.data);
console.error(`Actual cause: ${message}`);
export default () => next => action => {
// If not a promise, continue on
if (!isPromise(action.payload)) {
return next(action);
}
/**
*
* The notification middleware serves to dispatch the initial pending promise to
* the promise middleware, but adds a `then` and `catch.
*/
return next(action)
.then(response => {
if (action.meta && action.meta.successMessage) {
toast.success(action.meta.successMessage);
} else if (response && response.action && response.action.payload && response.action.payload.headers) {
const headers = response.action.payload.headers;
let alert: string = null;
let alertParams: string = null;
export default () => next => action => {
// If not a promise, continue on
if (!isPromise(action.payload)) {
return next(action);
}
/**
*
* The notification middleware serves to dispatch the initial pending promise to
* the promise middleware, but adds a `then` and `catch.
*/
return next(action)
.then(response => {
if (action.meta && action.meta.successMessage) {
toast.success(action.meta.successMessage);
} else if (response && response.action && response.action.payload && response.action.payload.headers) {
const headers = response.action.payload.headers;
let alert: string = null;
let alertParams: string = null;
export default () => next => action => {
// If not a promise, continue on
if (!isPromise(action.payload)) {
return next(action);
}
/**
*
* The notification middleware serves to dispatch the initial pending promise to
* the promise middleware, but adds a `then` and `catch.
*/
return next(action)
.then(response => {
if (action.meta && action.meta.successMessage) {
toast.success(action.meta.successMessage);
} else if (response && response.action && response.action.payload && response.action.payload.headers) {
const headers = response.action.payload.headers;
let alert: string = null;
let alertParams: string = null;
export default () => next => action => {
// If not a promise, continue on
if (!isPromise(action.payload)) {
return next(action);
}
/**
*
* The notification middleware serves to dispatch the initial pending promise to
* the promise middleware, but adds a `then` and `catch.
*/
return next(action).then(response => {
if (action.meta && action.meta.successMessage) {
if (typeof action.meta.successMessage === 'string') {
toast.success(action.meta.successMessage);
} else {
toast.success(action.meta.successMessage[0] + response.action.payload.data.id);
}
}
export default () => next => action => {
// If not a promise, continue on
if (!isPromise(action.payload)) {
return next(action);
}
/**
*
* The notification middleware serves to dispatch the initial pending promise to
* the promise middleware, but adds a `then` and `catch.
*/
return next(action)
.then(response => {
if (action.meta && action.meta.successMessage) {
toast.success(action.meta.successMessage);
} else if (response && response.action && response.action.payload && response.action.payload.headers) {
const headers = response.action.payload.headers;
let alert: string = null;
let alertParams: string = null;
export default () => next => action => {
// If not a promise, continue on
if (!isPromise(action.payload)) {
return next(action);
}
/**
*
* The notification middleware serves to dispatch the initial pending promise to
* the promise middleware, but adds a `then` and `catch.
*/
return next(action)
.then(response => {
if (action.meta && action.meta.successMessage) {
toast.success(action.meta.successMessage);
} else if (response && response.action && response.action.payload && response.action.payload.headers) {
const headers = response.action.payload.headers;
let alert: string = null;
let alertParams: string = null;