Returns a referral object by ID if it exists.
by hugo697 ยท 10/17/2025
1
//native
2
type Brex = {
3
token: string;
4
};
5
/**
6
* Gets a referral by ID
7
* Returns a referral object by ID if it exists.
8
*/
9
export async function main(auth: Brex, id: string) {
10
const url = new URL(`https://platform.brexapis.com/v1/referrals/${id}`);
11
12
const response = await fetch(url, {
13
method: "GET",
14
headers: {
15
Authorization: "Bearer " + auth.token,
16
},
17
body: undefined,
18
});
19
if (!response.ok) {
20
const text = await response.text();
21
throw new Error(`${response.status} ${text}`);
22
}
23
return await response.json();
24
25