Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 1x 2x 2x 2x 2x 2x 2x | import api from './api'
import type { ShoppingList, CreateListRequest, UpdateListRequest } from '../types'
export const listService = {
getAll(): Promise<ShoppingList[]> {
return api.get<ShoppingList[]>('/lists').then(r => r.data)
},
getOne(listId: string): Promise<ShoppingList> {
return api.get<ShoppingList>(`/lists/${listId}`).then(r => r.data)
},
create(req: CreateListRequest): Promise<ShoppingList> {
return api.post<ShoppingList>('/lists', req).then(r => r.data)
},
update(listId: string, req: UpdateListRequest): Promise<ShoppingList> {
return api.put<ShoppingList>(`/lists/${listId}`, req).then(r => r.data)
},
delete(listId: string): Promise<void> {
return api.delete(`/lists/${listId}`).then(() => undefined)
},
duplicate(listId: string): Promise<ShoppingList> {
return api.post<ShoppingList>(`/lists/${listId}/duplicate`).then(r => r.data)
},
}
|