added rating books
This commit is contained in:
@@ -42,11 +42,15 @@ export function getBook(id) {
|
||||
}
|
||||
|
||||
export function postBook(book) {
|
||||
return genericPostCall('/book', book.value)
|
||||
return genericPayloadCall('/book', book.value, 'POST')
|
||||
}
|
||||
|
||||
export async function postReadBook(userbook) {
|
||||
return genericPostCall('/book/read', userbook)
|
||||
export async function putReadBook(bookId) {
|
||||
return putBookUpdate(bookId, {read: true})
|
||||
}
|
||||
|
||||
export async function putBookUpdate(bookId, payload) {
|
||||
return genericPayloadCall('/book/' + bookId, payload, 'PUT')
|
||||
}
|
||||
|
||||
export function postLogin(user) {
|
||||
@@ -84,12 +88,12 @@ export function genericPostCallNoAuth(apiRoute, object) {
|
||||
})
|
||||
}
|
||||
|
||||
export function genericPostCall(apiRoute, object) {
|
||||
export function genericPayloadCall(apiRoute, object, method) {
|
||||
const { user } = useAuthStore();
|
||||
|
||||
if (user != null) {
|
||||
return fetch(baseUrl + apiRoute, {
|
||||
method: 'POST',
|
||||
method: method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + user.token
|
||||
|
||||
Reference in New Issue
Block a user