very basic post support + misc

This commit is contained in:
vimaexd 2024-07-05 14:51:32 +01:00
parent 7f993ee538
commit 5acb2e1667
36 changed files with 306 additions and 98 deletions

View file

@ -197,6 +197,28 @@ export async function getPost(host, token, post_id) {
return data;
}
/**
* POST /api/v1/statuses
* @param {string} host - The domain of the target server.
* @param {string} token - The application token
* @param {any} post_data - The post content
*/
export async function createPost(host, token, post_data) {
let formdata = new FormData();
for (const key in post_data) {
formdata.append(key, post_data[key]);
}
let url = `https://${host}/api/v1/statuses`;
const data = await fetch(url, {
method: 'POST',
headers: { "Authorization": `Bearer ${token}` },
body: formdata
})
return await data.json()
}
/**
* GET /api/v1/statuses/{post_id}/context.
* @param {string} host - The domain of the target server.
@ -336,4 +358,4 @@ export async function getUser(host, token, user_id) {
}).then(res => res.json());
return data;
}
}