Add retrospective API url injection
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
"@testing-library/react": "^9.3.2",
|
||||
"@testing-library/user-event": "^7.1.2",
|
||||
"@types/jest": "^24.0.0",
|
||||
"@types/node": "^12.0.0",
|
||||
"@types/node": "^14.14.25",
|
||||
"husky": "^4.3.7",
|
||||
"lint-staged": "^10.5.3",
|
||||
"prettier": "^2.2.1",
|
||||
|
||||
16
frontend/src/configs/api.config.ts
Normal file
16
frontend/src/configs/api.config.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export default class APIConfiguration {
|
||||
private static API_DEV = "https://api.beta.tsotr.humenius.me"
|
||||
private static API_PROD = "https://api.tsotr.humenius.me"
|
||||
private static API_LOCAL = "http://localhost:3500"
|
||||
|
||||
public static getUrl = (): string => {
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'production':
|
||||
return APIConfiguration.API_PROD;
|
||||
case 'development':
|
||||
return APIConfiguration.API_DEV;
|
||||
default:
|
||||
return APIConfiguration.API_LOCAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import APIConfiguration from "../configs/api.config";
|
||||
import RequestError from "../models/RequestError";
|
||||
import UserStatsResponse from "../models/UserStatsResponse";
|
||||
|
||||
export default class UserStatsService {
|
||||
|
||||
private static apiURL = 'https://api.tsotr.humenius.me/stats'
|
||||
//private static apiURL = 'http://localhost:3500/stats'
|
||||
private static readonly API_URL = APIConfiguration.getUrl();
|
||||
|
||||
private static requestInit: RequestInit = {
|
||||
method: 'GET',
|
||||
@@ -14,7 +14,7 @@ export default class UserStatsService {
|
||||
};
|
||||
|
||||
public static async getStats(seasonId?: string): Promise<UserStatsResponse> {
|
||||
return fetch(`${this.apiURL}/season/${seasonId ?? ''}`, this.requestInit)
|
||||
return fetch(`${UserStatsService.API_URL}/stats/season/${seasonId ?? ''}`, this.requestInit)
|
||||
.then(res => UserStatsService.checkResponse(res))
|
||||
.then(data => data.json())
|
||||
.then(data => {
|
||||
|
||||
@@ -1716,10 +1716,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.20.tgz#f7974863edd21d1f8a494a73e8e2b3658615c340"
|
||||
integrity sha512-Y93R97Ouif9JEOWPIUyU+eyIdyRqQR0I8Ez1dzku4hDx34NWh4HbtIc3WNzwB1Y9ULvNGeu5B8h8bVL5cAk4/A==
|
||||
|
||||
"@types/node@^12.0.0":
|
||||
version "12.19.12"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.19.12.tgz#04793c2afa4ce833a9972e4c476432e30f9df47b"
|
||||
integrity sha512-UwfL2uIU9arX/+/PRcIkT08/iBadGN2z6ExOROA2Dh5mAuWTBj6iJbQX4nekiV5H8cTrEG569LeX+HRco9Cbxw==
|
||||
"@types/node@^14.14.25":
|
||||
version "14.14.25"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.25.tgz#15967a7b577ff81383f9b888aa6705d43fbbae93"
|
||||
integrity sha512-EPpXLOVqDvisVxtlbvzfyqSsFeQxltFbluZNRndIb8tr9KiBnYNLzrc1N3pyKUCww2RNrfHDViqDWWE1LCJQtQ==
|
||||
|
||||
"@types/parse-json@^4.0.0":
|
||||
version "4.0.0"
|
||||
|
||||
Reference in New Issue
Block a user