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