//native
type Pinterest = {
token: string;
};
/**
* Follow user
* This endpoint is currently in beta and not available to all apps. Learn more.
Use this request, as a signed-in user, to follow another user.
*/
export async function main(
auth: Pinterest,
username: string,
body: { auto_follow?: false | true },
) {
const url = new URL(
`https://api.pinterest.com/v5/user_account/following/${username}`,
);
const response = await fetch(url, {
method: "POST",
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 536 days ago