Edits history of script submission #12580 for ' Get current profile (mollie)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Mollie = {
      token: string;
    };
    /**
     * Get current profile
     * Retrieve the currently authenticated profile. A convenient alias of the [Get profile](get-profile) endpoint.
    
    For a complete reference of the profile object, refer to the [Get profile](get-profile) endpoint documentation.
    
    > 🔑 Access with
    >
    > API key
     */
    export async function main(auth: Mollie) {
      const url = new URL(`https://api.mollie.com/v2/profiles/me`);
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 428 days ago