export async function main(
baseUrl: string,
accessToken: string,
status: string,
inReplyToId?: string,
sensitive = false,
spoilerText?: string,
visibility: "public" | "unlisted" | "private" | "direct" = "public",
language?: string,
) {
const resp = await fetch(`${baseUrl}/api/v1/statuses`, {
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
sensitive,
status,
visibility,
...(inReplyToId && {
in_reply_to_id: inReplyToId,
}),
...(spoilerText && {
spoiler_text: spoilerText,
}),
...(language && {
language,
}),
}),
});
if (!resp.ok) {
throw Error(`Failed to post status: Error HTTP${resp.status}`);
}
return await resp.json();
}
Submitted by admin 480 days ago
export async function main(
baseUrl: string,
accessToken: string,
status: string,
inReplyToId?: string,
sensitive = false,
spoilerText?: string,
visibility: "public" | "unlisted" | "private" | "direct" = "public",
language?: string,
) {
const resp = await fetch(`${baseUrl}/api/v1/statuses`, {
method: "POST",
headers: {
"Authorization": `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
sensitive,
status,
visibility,
...(inReplyToId && {
in_reply_to_id: inReplyToId,
}),
...(spoilerText && {
spoiler_text: spoilerText,
}),
...(language && {
language,
}),
}),
});
if (!resp.ok) {
throw Error(`Failed to post status: Error HTTP${resp.status}`);
}
return await resp.json();
}
Submitted by jaller94 848 days ago