Edits history of script submission #21044 for ' Get Lead (yelp)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Yelp = {
      apiKey: string;
    };
    /**
     * Get Lead
     * Returns details for a given Lead ID.
    
    Example:
    To fetch the details for a lead with the ID `jPlz8TM628rzyCRPqrtcvm`, send an [authenticated](https://docs.developer.yelp.com/docs/authorization-code-workflow) GET request to the following URL:
    https://api.yelp.com/v3/leads/jPlz8TM628rzyCRPqrtcvm
    
    A sample response is shown in the example response box on the right under "200 - Lead"
    
     */
    export async function main(auth: Yelp, ID: string) {
      const url = new URL(`https://api.yelp.com/v3/leads//${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