Edits history of script submission #23253 for ' Get Initiative Update (linear)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get Initiative Update
     * Get a single initiative status update by its ID.
     */
    export async function main(auth: RT.Linear, initiative_update_id: string) {
      const response = await fetch("https://api.linear.app/graphql", {
        method: "POST",
        headers: {
          Authorization: auth.apiKey,
          "Content-Type": "application/json",
          Accept: "application/json",
        },
        body: JSON.stringify({
          query: `query ($id: String!) { initiativeUpdate(id: $id) { id body health url createdAt updatedAt user { id name } initiative { id name } } }`,
          variables: { id: initiative_update_id },
        }),
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      const { data, errors } = await response.json()
      if (errors) {
        throw new Error(JSON.stringify(errors))
      }
    
      return data.initiativeUpdate
    }
    

    Submitted by hugo989 2 hours ago