embryo till sök
This commit is contained in:
@@ -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();
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user