Web: Common: Added getting api url from package.json, fixed "hardcode" from api client.

This commit is contained in:
Ilya Oleshko 2021-03-01 16:25:41 +03:00
parent a82ade029d
commit cb861508d3
2 changed files with 8 additions and 4 deletions

View File

@ -132,5 +132,9 @@
"engines": {
"node": ">=8",
"npm": ">=5"
},
"api": {
"url": "api/2.0",
"timeout": "30000"
}
}

View File

@ -1,9 +1,9 @@
import axios from "axios";
import config from "../../package.json";
//import history from "../history";
const PREFIX = "api";
const VERSION = "2.0";
const baseURL = `${window.location.origin}/${PREFIX}/${VERSION}`;
const baseURL = `${window.location.origin}/${config.api.url}`;
const apiTimeout = config.api.timeout;
/**
* @description axios instance for ajax requests
@ -12,7 +12,7 @@ const baseURL = `${window.location.origin}/${PREFIX}/${VERSION}`;
const client = axios.create({
baseURL: baseURL,
responseType: "json",
timeout: 30000, // default is `0` (no timeout)
timeout: apiTimeout, // default is `0` (no timeout)
});
client.interceptors.response.use(