La in dapper, och routing. fixade upp lite exempelsidor
This commit is contained in:
21
Frontend/src/services/bibblanservice.ts
Normal file
21
Frontend/src/services/bibblanservice.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { book, author } from "../types/types";
|
||||
|
||||
const BibblanService = {
|
||||
getBooks: async (
|
||||
authorid: string | undefined = undefined
|
||||
): Promise<book[]> => {
|
||||
let url = "/api/bibblan/books";
|
||||
if (authorid != undefined) {
|
||||
url += `/author/${authorid}`;
|
||||
}
|
||||
const response = await fetch(url);
|
||||
return response.json();
|
||||
},
|
||||
|
||||
getAuthors: async (): Promise<author[]> => {
|
||||
const response = await fetch("/api/bibblan/authors");
|
||||
return response.json();
|
||||
},
|
||||
};
|
||||
|
||||
export default BibblanService;
|
Reference in New Issue
Block a user