|
|
@@ -302,78 +302,4 @@ export default class AppContainer extends Container {
|
|
|
targetComponent.launchDrawioModal(beginLineNumber, endLineNumber);
|
|
|
}
|
|
|
|
|
|
- async apiGet(path, params) {
|
|
|
- return this.apiRequest('get', path, { params });
|
|
|
- }
|
|
|
-
|
|
|
- async apiPost(path, params) {
|
|
|
- if (!params._csrf) {
|
|
|
- params._csrf = this.csrfToken;
|
|
|
- }
|
|
|
-
|
|
|
- return this.apiRequest('post', path, params);
|
|
|
- }
|
|
|
-
|
|
|
- async apiDelete(path, params) {
|
|
|
- if (!params._csrf) {
|
|
|
- params._csrf = this.csrfToken;
|
|
|
- }
|
|
|
-
|
|
|
- return this.apiRequest('delete', path, { data: params });
|
|
|
- }
|
|
|
-
|
|
|
- async apiRequest(method, path, params) {
|
|
|
- const res = await axios[method](`/_api${path}`, params);
|
|
|
- if (res.data.ok) {
|
|
|
- return res.data;
|
|
|
- }
|
|
|
-
|
|
|
- // Return error code and data if error code exists
|
|
|
- if (res.data.code != null) {
|
|
|
- const error = new Apiv1ErrorHandler(res.data.error, res.data.code, res.data.data);
|
|
|
- throw error;
|
|
|
- }
|
|
|
-
|
|
|
- throw new Error(res.data.error);
|
|
|
- }
|
|
|
-
|
|
|
- async apiv3Request(method, path, params) {
|
|
|
- try {
|
|
|
- const res = await axios[method](urljoin(this.apiv3Root, path), params);
|
|
|
- return res.data;
|
|
|
- }
|
|
|
- catch (err) {
|
|
|
- const errors = apiv3ErrorHandler(err);
|
|
|
- throw errors;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- async apiv3Get(path, params) {
|
|
|
- return this.apiv3Request('get', path, { params });
|
|
|
- }
|
|
|
-
|
|
|
- async apiv3Post(path, params = {}) {
|
|
|
- if (!params._csrf) {
|
|
|
- params._csrf = this.csrfToken;
|
|
|
- }
|
|
|
-
|
|
|
- return this.apiv3Request('post', path, params);
|
|
|
- }
|
|
|
-
|
|
|
- async apiv3Put(path, params = {}) {
|
|
|
- if (!params._csrf) {
|
|
|
- params._csrf = this.csrfToken;
|
|
|
- }
|
|
|
-
|
|
|
- return this.apiv3Request('put', path, params);
|
|
|
- }
|
|
|
-
|
|
|
- async apiv3Delete(path, params = {}) {
|
|
|
- if (!params._csrf) {
|
|
|
- params._csrf = this.csrfToken;
|
|
|
- }
|
|
|
-
|
|
|
- return this.apiv3Request('delete', path, { params });
|
|
|
- }
|
|
|
-
|
|
|
}
|