feat(DNBApi): add api from deutsche national bibliothek

This commit is contained in:
0ry5 2024-09-25 21:33:17 +02:00
parent 46198913b1
commit 65e9aa2e0b
9 changed files with 1942 additions and 422 deletions
frontend/src/pages/Main/utils

View file

@ -0,0 +1,16 @@
import { Book } from "../../../types/Book";
export const tryGoogleBooksApi = async (
isbn: string
): Promise<Pick<Book, "published" | "title"> | undefined> => {
const googleBooks = await (
await fetch("https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn)
).json();
if ("items" in googleBooks) {
return {
published: googleBooks.items[0].volumeInfo.publishedDate.substring(0, 4),
title: googleBooks.items[0].volumeInfo.title,
};
}
return undefined;
};