mirror of
https://github.com/tcgdex/javascript-sdk.git
synced 2025-06-07 16:59:55 +00:00
Fixed Items with accents not being correctly fetched
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
040cb4508a
commit
2ac98526a1
@ -4,3 +4,5 @@
|
|||||||
tsconfig.json
|
tsconfig.json
|
||||||
*.ts
|
*.ts
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
test.js
|
||||||
|
test.d.ts
|
||||||
|
18
tcgdex.ts
18
tcgdex.ts
@ -15,8 +15,8 @@ export default class TCGdex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async fetchCard(id: string | number, set?: string): Promise<Card | undefined> {
|
public async fetchCard(id: string | number, set?: string): Promise<Card | undefined> {
|
||||||
const path = `/${set ? `sets/${set}` : 'cards'}/${id}/`
|
const path = set ? ['sets', set] : ['cards']
|
||||||
return this.rwgr<Card>(path).get()
|
return this.rwgr<Card>(...path, id).get()
|
||||||
}
|
}
|
||||||
|
|
||||||
public async fetchCards(set?: string): Promise<Array<CardResume> | undefined> {
|
public async fetchCards(set?: string): Promise<Array<CardResume> | undefined> {
|
||||||
@ -27,7 +27,7 @@ export default class TCGdex {
|
|||||||
}
|
}
|
||||||
return setSingle.cards
|
return setSingle.cards
|
||||||
}
|
}
|
||||||
const req = this.rwgr<Array<CardResume>>(`/cards/`)
|
const req = this.rwgr<Array<CardResume>>('cards')
|
||||||
const resp = await req.get()
|
const resp = await req.get()
|
||||||
if (!resp) {
|
if (!resp) {
|
||||||
return undefined
|
return undefined
|
||||||
@ -36,7 +36,7 @@ export default class TCGdex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async fetchSet(set: string): Promise<Set | undefined> {
|
public async fetchSet(set: string): Promise<Set | undefined> {
|
||||||
const req = this.rwgr<Set>(`/sets/${set}/`)
|
const req = this.rwgr<Set>('sets', set)
|
||||||
const resp = await req.get()
|
const resp = await req.get()
|
||||||
if (!resp) {
|
if (!resp) {
|
||||||
return undefined
|
return undefined
|
||||||
@ -45,12 +45,12 @@ export default class TCGdex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async fetchSerie(expansion: string): Promise<Serie | undefined> {
|
public async fetchSerie(expansion: string): Promise<Serie | undefined> {
|
||||||
const req = this.rwgr<Serie>(`/series/${expansion}/`)
|
const req = this.rwgr<Serie>('series', expansion)
|
||||||
return req.get()
|
return req.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
public async fetchSeries(): Promise<SerieList | undefined> {
|
public async fetchSeries(): Promise<SerieList | undefined> {
|
||||||
const req = this.rwgr<SerieList>(`/series/`)
|
const req = this.rwgr<SerieList>('series')
|
||||||
return req.get()
|
return req.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ export default class TCGdex {
|
|||||||
}
|
}
|
||||||
return expansionSingle.sets
|
return expansionSingle.sets
|
||||||
}
|
}
|
||||||
const req = this.rwgr<SetList>(`/sets/`)
|
const req = this.rwgr<SetList>('sets')
|
||||||
const list = await req.get()
|
const list = await req.get()
|
||||||
if (!list) {
|
if (!list) {
|
||||||
return undefined
|
return undefined
|
||||||
@ -70,7 +70,7 @@ export default class TCGdex {
|
|||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
private rwgr<T = any>(url: string) {
|
private rwgr<T = any>(...url: Array<string | number>) {
|
||||||
return RequestWrapper.getRequest<T>(`${this.getBaseUrl()}${url}`)
|
return RequestWrapper.getRequest<T>(`${this.getBaseUrl()}/${url.map((v) => encodeURI(v.toString())).join('/')}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user