0

Get Project Update

by
Published today

Get a single project status update by ID.

Script linear Verified

The script

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

3
/**
4
 * Get Project Update
5
 * Get a single project status update by its ID.
6
 */
7
export async function main(auth: RT.Linear, project_update_id: string) {
8
  const response = await fetch("https://api.linear.app/graphql", {
9
    method: "POST",
10
    headers: {
11
      Authorization: auth.apiKey,
12
      "Content-Type": "application/json",
13
      Accept: "application/json",
14
    },
15
    body: JSON.stringify({
16
      query: `query ($id: String!) { projectUpdate(id: $id) { id body health url createdAt updatedAt user { id name } project { id name } } }`,
17
      variables: { id: project_update_id },
18
    }),
19
  })
20

21
  if (!response.ok) {
22
    throw new Error(`${response.status} ${await response.text()}`)
23
  }
24

25
  const { data, errors } = await response.json()
26
  if (errors) {
27
    throw new Error(JSON.stringify(errors))
28
  }
29

30
  return data.projectUpdate
31
}
32