Get Nextcloud TaskProcessing Task
One script reply has been approved by the moderators Verified
Created by marcel klehr12 551 days ago Picked 8 times
Submitted by nextcloud Bun
Verified 21 days ago
1
import createClient, { type Middleware } from "openapi-fetch";
2

3

4
export async function main(
5
  nextcloud: RT.Nextcloud,
6
  taskId: string,
7
) {
8

9
  const client = createClient<paths>({ baseUrl: nextcloud.baseUrl });
10
  const authMiddleware: Middleware = {
11
    async onRequest({ request, options }) {
12
      // fetch token, if it doesn’t exist
13
      // add Authorization header to every request
14
      request.headers.set("Authorization", `Basic ${btoa((nextcloud.userId) + ':' + nextcloud.token)}`);
15
      return request;
16
    },
17
  };
18
  client.use(authMiddleware);
19

20
  const res = await client.GET("/ocs/v2.php/taskprocessing/task/{id}", {
21
    params: {
22
      header: {
23
        "OCS-APIRequest": true,
24
      },
25
      query: {
26
        format: "json",
27
      },
28
      path: {
29
        id: taskId,
30
      },
31

32
    },
33
  });
34
  return res.data;
35
}
Other submissions