0

List profiles

by
Published Apr 8, 2025

Retrieve a list of all of your profiles. The results are paginated. > 🔑 Access with > > Access token with **profiles.read**

Script mollie Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Mollie = {
3
  token: string;
4
};
5
/**
6
 * List profiles
7
 * Retrieve a list of all of your profiles.
8

9
The results are paginated.
10

11
> 🔑 Access with
12
>
13
> Access token with **profiles.read**
14
 */
15
export async function main(
16
  auth: Mollie,
17
  from: string | undefined,
18
  limit: string | undefined,
19
) {
20
  const url = new URL(`https://api.mollie.com/v2/profiles`);
21
  for (const [k, v] of [
22
    ["from", from],
23
    ["limit", limit],
24
  ]) {
25
    if (v !== undefined && v !== "") {
26
      url.searchParams.append(k, v);
27
    }
28
  }
29
  const response = await fetch(url, {
30
    method: "GET",
31
    headers: {
32
      Authorization: "Bearer " + auth.token,
33
    },
34
    body: undefined,
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.text();
41
}
42