embryo till sök

This commit is contained in:
2025-09-09 17:41:55 +02:00
parent 01e341fce0
commit e23822b30c
6 changed files with 76 additions and 12 deletions

View File

@@ -2,18 +2,27 @@ import { book, author } from "../types/types";
const BibblanService = {
getBooks: async (
authorid: string | undefined = undefined
authorid: string | undefined = undefined,
query: string | undefined = undefined
): Promise<book[]> => {
let url = "/api/bibblan/books";
if (authorid != undefined) {
url += `/author/${authorid}`;
} else if (query != undefined && query.length > 0) {
url += `?query=${encodeURIComponent(query)}`;
}
const response = await fetch(url);
return response.json();
},
getAuthors: async (): Promise<author[]> => {
const response = await fetch("/api/bibblan/authors");
getAuthors: async (
query: string | undefined = undefined
): Promise<author[]> => {
let url = "/api/bibblan/authors";
if (query != undefined && query.length > 0) {
url += `?query=${encodeURIComponent(query)}`;
}
const response = await fetch(url);
return response.json();
},
};