1 |
|
2 |
|
3 | type Nextcloud = { |
4 | baseUrl: string; |
5 | username: string; |
6 | password: string; |
7 | }; |
8 | export async function main(nextcloud_res: Nextcloud, userId: string) { |
9 | const resp = await fetch( |
10 | `${nextcloud_res.baseUrl}/ocs/v1.php/cloud/users/${encodeURIComponent( |
11 | userId, |
12 | )}`, |
13 | { |
14 | headers: { |
15 | Authorization: |
16 | "Basic " + |
17 | btoa(nextcloud_res.username + ":" + nextcloud_res.password), |
18 | "OCS-APIRequest": "true", |
19 | }, |
20 | }, |
21 | ); |
22 | if (!resp.ok) { |
23 | throw Error(`HTTP Error ${resp.status} - ${await resp.text()}`); |
24 | } |
25 | return await resp.text(); |
26 | } |
27 |
|