type Resend = {
token: string;
};
/**
* Update a single contact
*
*/
export async function main(
auth: Resend,
id: string,
audience_id: string,
body: {
email?: string;
first_name?: string;
last_name?: string;
unsubscribed?: boolean;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.resend.com/audiences/${audience_id}/contacts/${id}`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 399 days ago
type Resend = {
token: string;
};
/**
* Update a single contact
*
*/
export async function main(
auth: Resend,
id: string,
audience_id: string,
body: {
email?: string;
first_name?: string;
last_name?: string;
unsubscribed?: boolean;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.resend.com/audiences/${audience_id}/contacts/${id}`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 826 days ago