Add pagination for booksearch
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { ref } from 'vue'
|
||||
import { useAuthStore } from './auth.store.js'
|
||||
|
||||
const baseUrl = "http://localhost:8080"
|
||||
@@ -8,10 +7,7 @@ export function getImagePathOrDefault(path) {
|
||||
"../defaultbook.png" : baseUrl + path;
|
||||
}
|
||||
|
||||
function useFetch(url) {
|
||||
const data = ref(null);
|
||||
const error = ref(null);
|
||||
|
||||
function useFetch(data, error, url) {
|
||||
const { user } = useAuthStore();
|
||||
|
||||
if (user != null) {
|
||||
@@ -25,25 +21,28 @@ function useFetch(url) {
|
||||
.then((json) => (data.value = json))
|
||||
.catch((err) => (error.value = err));
|
||||
}
|
||||
|
||||
return { data, error }
|
||||
}
|
||||
|
||||
export function getCountMyBooks(arg) {
|
||||
return useFetch(baseUrl + '/mybooks/' + arg + "/count");
|
||||
export function getCountMyBooks(data, error, arg) {
|
||||
return useFetch(data, error, baseUrl + '/mybooks/' + arg + "/count");
|
||||
}
|
||||
|
||||
export function getMyBooks(arg, limit, offset) {
|
||||
export function getMyBooks(data, error, arg, limit, offset) {
|
||||
const queryParams = new URLSearchParams({limit: limit, offset: offset});
|
||||
return useFetch(baseUrl + '/mybooks/' + arg + "?" + queryParams.toString());
|
||||
return useFetch(data, error, baseUrl + '/mybooks/' + arg + "?" + queryParams.toString());
|
||||
}
|
||||
|
||||
export function getSearchBooks(searchterm) {
|
||||
return useFetch(baseUrl + '/search/' + searchterm);
|
||||
export function getCountSearchBooks(data, error, searchterm) {
|
||||
return useFetch(data, error,baseUrl + '/search/' + encodeURIComponent(searchterm) + '/count')
|
||||
}
|
||||
|
||||
export function getBook(id) {
|
||||
return useFetch(baseUrl + '/book/' + id);
|
||||
export function getSearchBooks(data, error, searchterm, limit, offset) {
|
||||
const queryParams = new URLSearchParams({limit: limit, offset: offset});
|
||||
return useFetch(data, error, baseUrl + '/search/' + encodeURIComponent(searchterm) + "?" + queryParams.toString());
|
||||
}
|
||||
|
||||
export function getBook(data, error, id) {
|
||||
return useFetch(data, error, baseUrl + '/book/' + id);
|
||||
}
|
||||
|
||||
export function postBook(book) {
|
||||
|
||||
Reference in New Issue
Block a user