Skip to content

Commit 0a7c843

Browse files
committed
constructor cant read class variables
1 parent 5ee2adb commit 0a7c843

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

src/api/base.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Constants } from 'src/constants';
44
import { ParamHelper } from 'src/utilities';
55

66
export class BaseAPI {
7-
apiBase: string; // API_BASE_PATH or PULP_API_BASE_PATH
87
apiPath: string;
98
// eslint-disable-next-line @typescript-eslint/no-explicit-any
109
http: any;
@@ -13,12 +12,12 @@ export class BaseAPI {
1312

1413
// a request URL is created from:
1514
// * API_HOST - optional, for use with different hostname
16-
// * apiBase - set by HubAPI, LegacyAPI & PulpAPI
15+
// * apiBaseUrl - api/pulp prefix, ends in trailing slash
1716
// * apiPath - set by leaf API classes
1817
// any extra id or params added by custom methods
19-
constructor() {
18+
constructor(apiBaseUrl) {
2019
this.http = axios.create({
21-
baseURL: API_HOST + this.apiBase,
20+
baseURL: API_HOST + apiBaseUrl,
2221
paramsSerializer: {
2322
serialize: (params) => ParamHelper.getQueryString(params),
2423
},

src/api/hub.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { BaseAPI } from './base';
22

33
export class HubAPI extends BaseAPI {
4-
apiBase = API_BASE_PATH;
54
mapPageToOffset = true; // offset & limit
65
sortParam = 'sort';
6+
7+
constructor() {
8+
super(API_BASE_PATH);
9+
}
710
}

src/api/legacy.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { BaseAPI } from './base';
22

33
export class LegacyAPI extends BaseAPI {
4-
apiBase = API_BASE_PATH;
54
mapPageToOffset = false; // page & page_size
65
sortParam = 'order_by';
6+
7+
constructor() {
8+
super(API_BASE_PATH);
9+
}
710
}

src/api/pulp.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { BaseAPI } from './base';
22

33
export class PulpAPI extends BaseAPI {
4-
apiBase = PULP_API_BASE_PATH;
54
mapPageToOffset = true; // offset & limit
65
sortParam = 'ordering';
6+
7+
constructor() {
8+
super(PULP_API_BASE_PATH);
9+
}
710
}

0 commit comments

Comments
 (0)