//native
type Segment = {
token: string;
baseUrl: string;
};
/**
* Get Audience
* Returns the Audience by id and spaceId.
*/
export async function main(auth: Segment, spaceId: string, id: string) {
const url = new URL(
`${auth.baseUrl}/spaces/${spaceId}/audiences/${id}`,
);
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 235 days ago