Edits history of script submission #21046 for ' Get Monthly Report (yelp)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Yelp = {
      apiKey: string;
    };
    /**
     * Get Monthly Report
     * Fetch the monthly report associated with {report_id}.
    
     */
    export async function main(auth: Yelp, report_id: string) {
      const url = new URL(
        `https://api.yelp.com/v3/reporting//businesses/monthly/${report_id}`,
      );
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + 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