Explorar el Código

Added toast message to all server errors

feature/508
Djordje Mitrovic hace 3 años
padre
commit
825daa72ef

+ 1
- 0
.env Ver fichero

@@ -0,0 +1 @@
REACT_APP_BASE_API_URL=https://trampa-api-test.dilig.net/

+ 0
- 1
.gitignore Ver fichero

@@ -13,7 +13,6 @@

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local

+ 1
- 1
src/i18n/resources/rs.js Ver fichero

@@ -172,7 +172,7 @@ export default {
product: "Proizvod",
},
apiErrors: {
somethingWentWrong: "Greska sa serverom!",
somethingWentWrong: "Greška sa serverom!",
},
header: {
addOffer: "Dodaj proizvod",

+ 2
- 1
src/request/index.js Ver fichero

@@ -6,7 +6,8 @@ const request = axios.create({
// baseURL: "http://192.168.88.175:3005/",
// baseURL: "http://192.168.88.143:3001/", // DULE
// baseURL: "https://trampa-api-test.dilig.net/",
baseURL: "http://localhost:3001/",
// baseURL: "http://localhost:3001/",
baseURL: process.env.REACT_APP_BASE_API_URL,
headers: {
"Content-Type": "application/json",
},

+ 2
- 1
src/socket/socket.js Ver fichero

@@ -1,7 +1,8 @@
import io from "socket.io-client";

// export const socket = io("https://trampa-api-test.dilig.net/", {
export const socket = io("http://localhost:3001/", {
// export const socket = io("http://localhost:3001/", {
export const socket = io(process.env.REACT_APP_BASE_API_URL, {
transports: ["websocket"],
reconnectionAttempts: 5,
});

+ 2
- 1
src/store/middleware/accessTokensMiddleware.js Ver fichero

@@ -17,7 +17,8 @@ import { logoutUser, refreshUserToken } from "../actions/login/loginActions";
// const baseURL = "http://192.168.88.175:3005/";
// const baseURL = "https://trampa-api-test.dilig.net/";
// const baseURL = "http://192.168.88.150:3001/"; // DJOLE
const baseURL = "http://localhost:3001/";
// const baseURL = "http://localhost:3001/";
const baseURL = process.env.REACT_APP_BASE_API_URL

//Interceptor unique name
export const accessTokensMiddlewareInterceptorName = "ACCESS_TOKEN_INTERCEPTOR";

+ 5
- 3
src/store/middleware/internalServerErrorMiddleware.js Ver fichero

@@ -1,4 +1,6 @@
import i18next from "i18next";
import { attachPostRequestListener } from "../../request";
import { makeErrorToastMessage } from "../utils/makeToastMessage";

//Interceptor unique name
export const serverErrorMiddlewareInterceptorName =
@@ -7,12 +9,12 @@ export const serverErrorMiddlewareInterceptorName =
export default () => (next) => (action) => {
attachPostRequestListener((error) => {
if (!error.response) {
return Promise.reject(error);
return makeErrorToastMessage(i18next.t("apiErrors.somethingWentWrong"));
}
if (error.response.status === 500) {
return "aaa";
return makeErrorToastMessage(i18next.t("apiErrors.somethingWentWrong"));
}
return Promise.reject(error);
return makeErrorToastMessage(i18next.t("apiErrors.somethingWentWrong"));
}, serverErrorMiddlewareInterceptorName);

next(action);

Cargando…
Cancelar
Guardar