mirror of
https://github.com/thegeneralist01/archivr
synced 2026-07-21 18:55:36 +02:00
feat(collections): frontend — api.js updateCollection and deleteCollection helpers
This commit is contained in:
parent
383cec1f81
commit
c4ce2129bb
1 changed files with 14 additions and 0 deletions
|
|
@ -285,6 +285,20 @@ export async function listEntryCollections(archiveId, entryUid) {
|
|||
return getJson(`/api/archives/${archiveId}/entries/${entryUid}/collections`);
|
||||
}
|
||||
|
||||
export async function updateCollection(archiveId, collUid, patch) {
|
||||
const res = await fetch(`/api/archives/${archiveId}/collections/${collUid}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(patch),
|
||||
})
|
||||
if (!res.ok) { const e = await res.json().catch(() => ({})); throw new Error(e.error ?? res.statusText) }
|
||||
}
|
||||
|
||||
export async function deleteCollection(archiveId, collUid) {
|
||||
const res = await fetch(`/api/archives/${archiveId}/collections/${collUid}`, { method: 'DELETE' })
|
||||
if (!res.ok) { const e = await res.json().catch(() => ({})); throw new Error(e.error ?? res.statusText) }
|
||||
}
|
||||
|
||||
// ── 401 interceptor ───────────────────────────────────────────────────────────
|
||||
const _origFetch = window.fetch;
|
||||
window.fetch = async (...args) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue