Files
Frontend/src/app/common/hastebin.ts

18 lines
461 B
TypeScript
Raw Normal View History

2024-04-23 17:52:37 +01:00
const HASTE_URL: string = "https://paste.fascinated.cc";
/**
* Creates a new haste with the given content.
*
* @param content the content to create the haste with
* @returns the URL of the created haste
*/
export async function createHaste(content: string): Promise<string> {
2024-04-23 17:52:37 +01:00
const response = await fetch(`${HASTE_URL}/api/upload`, {
method: "POST",
body: content,
});
2024-04-23 17:52:37 +01:00
const { id } = await response.json();
return `${HASTE_URL}/${id}`;
}