30 lines
482 B
JavaScript
30 lines
482 B
JavaScript
|
|
export class APIClient {
|
|
|
|
saveBoard(board) {
|
|
return fetch(`/api/boards`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(board)
|
|
})
|
|
.then(res => res.json())
|
|
;
|
|
}
|
|
|
|
deleteBoard(id) {
|
|
return fetch(`/api/boards/${id}`, {
|
|
method: 'DELETE'
|
|
});
|
|
}
|
|
|
|
fetchBoards() {
|
|
return fetch(`/api/boards`)
|
|
.then(res => res.json())
|
|
;
|
|
}
|
|
|
|
}
|
|
|
|
export const api = new APIClient(); |