18 lines
462 B
TypeScript
18 lines
462 B
TypeScript
|
const HASTE_URL: string = "https://haste.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> {
|
||
|
const response = await fetch(`${HASTE_URL}/documents`, {
|
||
|
method: "POST",
|
||
|
body: content,
|
||
|
});
|
||
|
|
||
|
const { key } = await response.json();
|
||
|
return `${HASTE_URL}/${key}`;
|
||
|
}
|