aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/workspaces/api.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/workspaces/api.ts')
-rw-r--r--src/features/workspaces/api.ts19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/features/workspaces/api.ts b/src/features/workspaces/api.ts
index 582433527..fb752c565 100644
--- a/src/features/workspaces/api.ts
+++ b/src/features/workspaces/api.ts
@@ -4,15 +4,14 @@ import Request from '../../stores/lib/Request';
4import Workspace from './models/Workspace'; 4import Workspace from './models/Workspace';
5import apiBase from '../../api/apiBase'; 5import apiBase from '../../api/apiBase';
6 6
7// TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed 7const debug = require('../../preload-safe-debug')('Ferdium:feature:workspaces:api');
8// const debug = require('debug')('Ferdium:feature:workspaces:api');
9 8
10export const workspaceApi = { 9export const workspaceApi = {
11 getUserWorkspaces: async () => { 10 getUserWorkspaces: async () => {
12 const url = `${apiBase()}/workspace`; 11 const url = `${apiBase()}/workspace`;
13 console.log('getUserWorkspaces GET', url); 12 debug('getUserWorkspaces GET', url);
14 const result = await sendAuthRequest(url, { method: 'GET' }); 13 const result = await sendAuthRequest(url, { method: 'GET' });
15 console.log('getUserWorkspaces RESULT', result); 14 debug('getUserWorkspaces RESULT', result);
16 if (!result.ok) { 15 if (!result.ok) {
17 throw new Error("Couldn't getUserWorkspaces"); 16 throw new Error("Couldn't getUserWorkspaces");
18 } 17 }
@@ -26,9 +25,9 @@ export const workspaceApi = {
26 method: 'POST', 25 method: 'POST',
27 body: JSON.stringify({ name }), 26 body: JSON.stringify({ name }),
28 }; 27 };
29 console.log('createWorkspace POST', url, options); 28 debug('createWorkspace POST', url, options);
30 const result = await sendAuthRequest(url, options); 29 const result = await sendAuthRequest(url, options);
31 console.log('createWorkspace RESULT', result); 30 debug('createWorkspace RESULT', result);
32 if (!result.ok) { 31 if (!result.ok) {
33 throw new Error("Couldn't createWorkspace"); 32 throw new Error("Couldn't createWorkspace");
34 } 33 }
@@ -37,9 +36,9 @@ export const workspaceApi = {
37 36
38 deleteWorkspace: async workspace => { 37 deleteWorkspace: async workspace => {
39 const url = `${apiBase()}/workspace/${workspace.id}`; 38 const url = `${apiBase()}/workspace/${workspace.id}`;
40 console.log('deleteWorkspace DELETE', url); 39 debug('deleteWorkspace DELETE', url);
41 const result = await sendAuthRequest(url, { method: 'DELETE' }); 40 const result = await sendAuthRequest(url, { method: 'DELETE' });
42 console.log('deleteWorkspace RESULT', result); 41 debug('deleteWorkspace RESULT', result);
43 if (!result.ok) { 42 if (!result.ok) {
44 throw new Error("Couldn't deleteWorkspace"); 43 throw new Error("Couldn't deleteWorkspace");
45 } 44 }
@@ -52,9 +51,9 @@ export const workspaceApi = {
52 method: 'PUT', 51 method: 'PUT',
53 body: JSON.stringify(pick(workspace, ['name', 'services'])), 52 body: JSON.stringify(pick(workspace, ['name', 'services'])),
54 }; 53 };
55 console.log('updateWorkspace UPDATE', url, options); 54 debug('updateWorkspace UPDATE', url, options);
56 const result = await sendAuthRequest(url, options); 55 const result = await sendAuthRequest(url, options);
57 console.log('updateWorkspace RESULT', result); 56 debug('updateWorkspace RESULT', result);
58 if (!result.ok) { 57 if (!result.ok) {
59 throw new Error("Couldn't updateWorkspace"); 58 throw new Error("Couldn't updateWorkspace");
60 } 59 }