0

List research tasks

Published today

List the research tasks created by your Linkup organization, paginated.

Script linkup Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 3 hours ago
1
//native
2

3
/**
4
 * List research tasks
5
 * List the research tasks created by your Linkup organization, paginated.
6
 */
7
export async function main(
8
  auth: RT.Linkup,
9
  page: number | undefined,
10
  page_size: number | undefined,
11
  sort_by: "createdAt" | "updatedAt" | undefined,
12
  sort_direction: "asc" | "desc" | undefined
13
) {
14
  const url = new URL("https://api.linkup.so/v1/research")
15
  if (page != null) url.searchParams.append("page", String(page))
16
  if (page_size != null) url.searchParams.append("pageSize", String(page_size))
17
  if (sort_by != null && sort_by !== "")
18
    url.searchParams.append("sortBy", sort_by)
19
  if (sort_direction != null && sort_direction !== "") {
20
    url.searchParams.append("sortDirection", sort_direction)
21
  }
22

23
  const response = await fetch(url, {
24
    method: "GET",
25
    headers: {
26
      Authorization: `Bearer ${auth.token}`,
27
      Accept: "application/json",
28
    },
29
  })
30

31
  if (!response.ok) {
32
    throw new Error(`${response.status} ${await response.text()}`)
33
  }
34

35
  return await response.json()
36
}
37