Web: Common: Added getting api url from package.json, fixed "hardcode" from api client.
This commit is contained in:
parent
a82ade029d
commit
cb861508d3
@ -132,5 +132,9 @@
|
||||
"engines": {
|
||||
"node": ">=8",
|
||||
"npm": ">=5"
|
||||
},
|
||||
"api": {
|
||||
"url": "api/2.0",
|
||||
"timeout": "30000"
|
||||
}
|
||||
}
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user