Edits history of script submission #23233 for ' Star Repository (github)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Star Repository
     * Star a repository as the authenticated user.
     */
    export async function main(auth: RT.Github, owner: string, repo: string) {
      const response = await fetch(
        `https://api.github.com/user/starred/${owner}/${repo}`,
        {
          method: "PUT",
          headers: {
            Authorization: `Bearer ${auth.token}`,
            Accept: "application/vnd.github+json",
            "X-GitHub-Api-Version": "2022-11-28",
          },
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return { success: true }
    }
    

    Submitted by hugo989 2 hours ago