Make sure exchange API response format is valid before using it
This commit is contained in:
@@ -13,7 +13,11 @@ class BitflyerApi implements PriceFeed {
|
||||
|
||||
public async $fetchPrice(currency): Promise<number> {
|
||||
const response = await query(this.url + currency);
|
||||
return response ? parseInt(response['ltp'], 10) : -1;
|
||||
if (response && response['ltp']) {
|
||||
return parseInt(response['ltp'], 10);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public async $fetchRecentPrice(currencies: string[], type: 'hour' | 'day'): Promise<PriceHistory> {
|
||||
|
||||
Reference in New Issue
Block a user