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
|
@ -0,0 +1,29 @@
|
|||
import { XMLParser } from "fast-xml-parser";
|
||||
import { Book } from "../../../types/Book";
|
||||
|
||||
export const tryDeutscheNationalBibliothekApi = async (
|
||||
isbn: string
|
||||
): Promise<Pick<Book, "published" | "title"> | undefined> => {
|
||||
const parser = new XMLParser();
|
||||
|
||||
const foundBooks = parser.parse(
|
||||
await (
|
||||
await fetch(
|
||||
"https://services.dnb.de/sru/dnb?version=1.1&operation=searchRetrieve&query=" +
|
||||
isbn
|
||||
)
|
||||
).text()
|
||||
);
|
||||
const foundBook =
|
||||
foundBooks.searchRetrieveResponse?.records?.record?.recordData?.[
|
||||
"rdf:RDF"
|
||||
]?.["rdf:Description"];
|
||||
|
||||
if (!!foundBook) {
|
||||
return {
|
||||
published: foundBook["dcterms:issued"],
|
||||
title: foundBook["dc:title"],
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue