Edits history of script submission #21048 for ' Get details of a visit (yelp)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Yelp = {
      apiKey: string;
    };
    /**
     * Get details of a visit
     * Get the visit details by the given encrypted visit identifier.
     */
    export async function main(auth: Yelp, visit_id: string) {
      const url = new URL(`https://api.yelp.com/v3/visits/${visit_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