gengitkan/client/src/util/api.ts

30 lines
482 B
TypeScript
Raw Normal View History

2019-12-01 22:12:13 +01:00
export class APIClient {
saveBoard(board) {
return fetch(`/api/boards`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(board)
})
.then(res => res.json())
;
}
2019-12-13 13:28:59 +01:00
deleteBoard(id) {
return fetch(`/api/boards/${id}`, {
method: 'DELETE'
});
}
2019-12-01 22:12:13 +01:00
fetchBoards() {
return fetch(`/api/boards`)
.then(res => res.json())
;
}
}
export const api = new APIClient();