aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/workspaces/api.js
blob: 65108a077fb31fb15bb6a23e2a36bb1a2244d408 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { prepareAuthRequest } from '../../api/utils/auth';
import { API, API_VERSION } from '../../environment';

export default {
  getUserWorkspaces: async () => {
    const url = `${API}/${API_VERSION}/workspace`;
    const request = await window.fetch(url, prepareAuthRequest({
      method: 'GET',
    }));
    if (!request.ok) throw request;
    return request.json();
  },
  createWorkspace: async (name) => {
    const url = `${API}/${API_VERSION}/workspace`;
    const request = await window.fetch(url, prepareAuthRequest({
      method: 'POST',
      body: JSON.stringify({ name }),
    }));
    if (!request.ok) throw request;
    return request.json();
  },
};