Edits history of script submission #21002 for ' Linked Locations (tomorrow)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Tomorrow = {
      apiKey: string;
    };
    /**
     * Linked Locations
     *
     */
    export async function main(
      auth: Tomorrow,
      alertId: string,
      Accept_Encoding?: string,
    ) {
      const url = new URL(`https://api.tomorrow.io/v4/alerts/${alertId}/locations`);
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          ...(Accept_Encoding ? { "Accept-Encoding": Accept_Encoding } : {}),
          ApiKey: auth.apiKey,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago