refactor(web): migrate playlists.ts to api.* wrapper (#375)
Drop 9 hand-rolled apiFetch calls with redundant Content-Type headers + manual JSON.stringify. The api.* wrapper in client.ts already handles both. Identical wire shape; existing tests cover all endpoints. Also makes api.del generic so DELETE endpoints with typed returns (playlist track removal) can use the wrapper instead of raw apiFetch. Default `T = null` preserves existing callers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -58,6 +58,6 @@ export const api = {
|
||||
apiFetch(path, { method: 'PUT', body: JSON.stringify(body) }) as Promise<T>,
|
||||
patch: <T>(path: string, body: unknown): Promise<T> =>
|
||||
apiFetch(path, { method: 'PATCH', body: JSON.stringify(body) }) as Promise<T>,
|
||||
del: (path: string): Promise<null> =>
|
||||
apiFetch(path, { method: 'DELETE' }) as Promise<null>
|
||||
del: <T = null>(path: string): Promise<T> =>
|
||||
apiFetch(path, { method: 'DELETE' }) as Promise<T>
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user