Edits history of script submission #13001 for ' Update api key (speechify)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Speechify = {
      token: string;
    };
    /**
     * Update api key
     * Update API key name for the logged in user
     */
    export async function main(auth: Speechify, id: string, body: string) {
      const url = new URL(`https://api.sws.speechify.com/v1/token/${id}`);
    
      const response = await fetch(url, {
        method: "PATCH",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 428 days ago