Created
May 28, 2021 02:48
-
-
Save deguchi/1a64d4ecbba5a0fa57269d632a3716e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async getOpenBDInfo(item): Promise<any> { | |
const books = await fetch('https://api.openbd.jp/v1/get?isbn='+item.isbn).then(r => r.json()).catch(error => console.log(error)) | |
if (books.length>0) { | |
const book = books[0] | |
console.log(book) | |
// 紹介・目次 | |
let description = null | |
let descriptionLong = null | |
let tableOfContents = null | |
const CollateralDetails = book.onix.CollateralDetail.TextContent | |
if (CollateralDetails) { | |
for (const CollateralDetail of CollateralDetails) { | |
const TextType = CollateralDetail.TextType | |
if (TextType === '02') description = CollateralDetail.Text | |
if (TextType === '03') descriptionLong = CollateralDetail.Text | |
if (TextType === '04') tableOfContents = CollateralDetail.Text | |
} | |
} | |
const maegakinado = typeof book.hanmoto.maegakinado!=='undefined' ? book.hanmoto.maegakinado : null | |
const hastameshiyomi = typeof book.hanmoto.hastameshiyomi!=='undefined' ? book.hanmoto.hastameshiyomi : null | |
return { | |
'description': description, | |
'descriptionLong': descriptionLong, | |
'tableOfContents': tableOfContents, | |
'maegakinado': maegakinado, | |
'hastameshiyomi': hastameshiyomi, | |
} | |
} | |
return null | |
} | |
const openBDInfo = await this.getOpenBDInfo(viewItem) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment