feat(DNBApi): add api from deutsche national bibliothek
This commit is contained in:
parent
46198913b1
commit
65e9aa2e0b
9 changed files with 1942 additions and 422 deletions
frontend/src/pages/Main/utils
16
frontend/src/pages/Main/utils/tryGoogleBooksApi.ts
Normal file
16
frontend/src/pages/Main/utils/tryGoogleBooksApi.ts
Normal 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;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue