import { attachPostRequestListener } from "../../request";

//Interceptor unique name
export const serverErrorMiddlewareInterceptorName =
  "INTERNAL_SERVER_ERROR_MIDDLEWARE_INTERCEPTOR";

export default () => (next) => (action) => {
  attachPostRequestListener((error) => {
    if (!error.response) {
      return Promise.reject(error);
    }
    if (error.response.status === 500) {
      return "aaa";
    }
    return Promise.reject(error);
  }, serverErrorMiddlewareInterceptorName);

  next(action);
};
