mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
|
// getAPIInformation returns the API information
|
||
|
export async function getAPIInformation() {
|
||
|
return await fetch(location.protocol + "//" + location.host + "/api/v1/info");
|
||
|
}
|
||
|
|
||
|
// getPaste retrieves a paste
|
||
|
export async function getPaste(id) {
|
||
|
return await fetch(location.protocol + "//" + location.host + "/api/v1/pastes/" + id);
|
||
|
}
|
||
|
|
||
|
// createPaste creates a new paste
|
||
|
export async function createPaste(content) {
|
||
|
return await fetch(location.protocol + "//" + location.host + "/api/v1/pastes", {
|
||
|
method: 'POST',
|
||
|
headers: {
|
||
|
'Content-Type': 'application/json'
|
||
|
},
|
||
|
body: JSON.stringify({
|
||
|
content
|
||
|
})
|
||
|
});
|
||
|
}
|
||
|
|
||
|
// deletePaste deletes a paste
|
||
|
export async function deletePaste(id, deletionToken) {
|
||
|
return await fetch(location.protocol + "//" + location.host + "/api/v1/pastes/" + id, {
|
||
|
method: 'DELETE',
|
||
|
headers: {
|
||
|
'Content-Type': 'application/json'
|
||
|
},
|
||
|
body: JSON.stringify({
|
||
|
deletionToken
|
||
|
})
|
||
|
});
|
||
|
}
|