fix(frontend): add data parameter support to apiDelete
- Add optional data parameter to apiDelete() with generic type safety - Enables DELETE requests with request bodies (needed for folder deletion) - 100% backward compatible (optional parameter) - Supports type-safe request body passing Part of: Issue 1
This commit is contained in:
+5
-3
@@ -34,12 +34,14 @@ async function apiPut(url: string, data?: unknown): Promise<Response> {
|
||||
});
|
||||
}
|
||||
|
||||
async function apiDelete(url: string): Promise<Response> {
|
||||
async function apiDelete<T extends object>(url: string, data?: T): Promise<Response> {
|
||||
return fetch(`/api${url}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Authorization': getAuthHeader()
|
||||
}
|
||||
'Authorization': getAuthHeader(),
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: data ? JSON.stringify(data) : undefined
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user