0

Get current profile

by
Published Apr 8, 2025

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

Script mollie Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Mollie = {
3
  token: string;
4
};
5
/**
6
 * Get current profile
7
 * Retrieve the currently authenticated profile. A convenient alias of the [Get profile](get-profile) endpoint.
8

9
For a complete reference of the profile object, refer to the [Get profile](get-profile) endpoint documentation.
10

11
> 🔑 Access with
12
>
13
> API key
14
 */
15
export async function main(auth: Mollie) {
16
  const url = new URL(`https://api.mollie.com/v2/profiles/me`);
17

18
  const response = await fetch(url, {
19
    method: "GET",
20
    headers: {
21
      Authorization: "Bearer " + auth.token,
22
    },
23
    body: undefined,
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.text();
30
}
31