import { book, author } from "../types/types"; const BibblanService = { getBooks: async ( authorid: string | undefined = undefined, query: string | undefined = undefined ): Promise => { 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 ( query: string | undefined = undefined ): Promise => { let url = "/api/bibblan/authors"; if (query != undefined && query.length > 0) { url += `?query=${encodeURIComponent(query)}`; } const response = await fetch(url); return response.json(); }, getSeries: async ( query: string | undefined = undefined ): Promise => { let url = "/api/bibblan/series"; if (query != undefined && query.length > 0) { url += `?query=${encodeURIComponent(query)}`; } const response = await fetch(url); return response.json(); }, }; export default BibblanService;