From 04d13bd450a794641aec68af477c97b3c54533e3 Mon Sep 17 00:00:00 2001 From: Avior Date: Sat, 14 Mar 2020 19:56:59 +0100 Subject: [PATCH] Updated DB to add items Signed-off-by: Avior --- interfaces/Card.ts | 8 ++++++++ tcgdex.ts | 12 +++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/interfaces/Card.ts b/interfaces/Card.ts index 7538716..bf31d54 100644 --- a/interfaces/Card.ts +++ b/interfaces/Card.ts @@ -33,6 +33,14 @@ export interface CardSingle { name: string code: string } + + /** + * Some Pokémons have item like a berry + */ + item?: { + name: LangList + effect: LangList + } cardTypes?: { /** * normal card without anything special diff --git a/tcgdex.ts b/tcgdex.ts index adcc848..f052d2e 100644 --- a/tcgdex.ts +++ b/tcgdex.ts @@ -1,7 +1,7 @@ import fetch from 'isomorphic-unfetch' import { Langs } from './interfaces/Langs' -import { SetSingle, SetRequest, SetSimple } from './interfaces/Set' -import { CardSingle } from './interfaces/Card' +import { SetSingle, SetRequest, SetSimple, SetList } from './interfaces/Set' +import { CardSingle, CardList, CardSimple } from './interfaces/Card' import { ExpansionSingle, ExpansionList } from './interfaces/Expansion' export default class TCGdex { @@ -36,7 +36,7 @@ export default class TCGdex { } } - public async getCards(set?: string) { + public async getCards(set?: string): Promise> { if (set) { try { const setSingle = await this.getSet(set) @@ -52,7 +52,8 @@ export default class TCGdex { throw new Error("Could not fetch cards") } try { - return resp.json() + const t: CardList = await resp.json() + return t.list } catch (e) { throw e } @@ -120,7 +121,8 @@ export default class TCGdex { throw new Error("Could not fetch sets") } try { - return resp.json() + const sets: SetList = await resp.json() + return sets.list } catch (e) { throw e }