diff --git a/package-lock.json b/package-lock.json index a651a8341..f0c87de4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "5.2.1", "license": "MIT", "dependencies": { - "@tf2autobot/bptf-listings": "^5.6.4", + "@tf2autobot/bptf-listings": "^5.6.5", "@tf2autobot/bptf-login": "^2.3.4", "@tf2autobot/filter-axios-error": "^1.4.0", "@tf2autobot/jsonlint": "^1.0.0", @@ -1958,9 +1958,9 @@ "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==" }, "node_modules/@tf2autobot/bptf-listings": { - "version": "5.6.4", - "resolved": "https://registry.npmjs.org/@tf2autobot/bptf-listings/-/bptf-listings-5.6.4.tgz", - "integrity": "sha512-HjwQcnSFpYvOcO/2ga7jAGFBtaKKRwZWWxbIjmAemTMvA420eOCC2yAfuGfUBvzaDB/O7YzYmXmLIfstpb2dJA==", + "version": "5.6.5", + "resolved": "https://registry.npmjs.org/@tf2autobot/bptf-listings/-/bptf-listings-5.6.5.tgz", + "integrity": "sha512-ZVExpAp432lxf5bjSCrqbiSPayRRPGHObhbuJnmbMPyRYiG6bCJ0v0U1tiwZA8M+mtwssfWgYUynrcpzxho0Qg==", "dependencies": { "@tf2autobot/filter-axios-error": "^1.4.0", "@tf2autobot/tf2-currencies": "^2.0.1", @@ -12429,9 +12429,9 @@ "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==" }, "@tf2autobot/bptf-listings": { - "version": "5.6.4", - "resolved": "https://registry.npmjs.org/@tf2autobot/bptf-listings/-/bptf-listings-5.6.4.tgz", - "integrity": "sha512-HjwQcnSFpYvOcO/2ga7jAGFBtaKKRwZWWxbIjmAemTMvA420eOCC2yAfuGfUBvzaDB/O7YzYmXmLIfstpb2dJA==", + "version": "5.6.5", + "resolved": "https://registry.npmjs.org/@tf2autobot/bptf-listings/-/bptf-listings-5.6.5.tgz", + "integrity": "sha512-ZVExpAp432lxf5bjSCrqbiSPayRRPGHObhbuJnmbMPyRYiG6bCJ0v0U1tiwZA8M+mtwssfWgYUynrcpzxho0Qg==", "requires": { "@tf2autobot/filter-axios-error": "^1.4.0", "@tf2autobot/tf2-currencies": "^2.0.1", diff --git a/package.json b/package.json index cea768233..75632176b 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "updateMessage": "", "homepage": "https://github.com/TF2Autobot/tf2autobot#readme", "dependencies": { - "@tf2autobot/bptf-listings": "^5.6.4", + "@tf2autobot/bptf-listings": "^5.6.5", "@tf2autobot/bptf-login": "^2.3.4", "@tf2autobot/filter-axios-error": "^1.4.0", "@tf2autobot/jsonlint": "^1.0.0", diff --git a/src/lib/pricer/pricestf/prices-tf-api.ts b/src/lib/pricer/pricestf/prices-tf-api.ts index 0834da348..e6391d5be 100644 --- a/src/lib/pricer/pricestf/prices-tf-api.ts +++ b/src/lib/pricer/pricestf/prices-tf-api.ts @@ -1,5 +1,5 @@ import axios, { AxiosRequestConfig, Method, AxiosError } from 'axios'; -import filterAxiosError from '@tf2autobot/filter-axios-error'; +import filterAxiosError, { ErrorFiltered } from '@tf2autobot/filter-axios-error'; import { PricerOptions } from '../../../classes/IPricer'; import log from '../../logger'; @@ -63,8 +63,8 @@ export default class PricesTfApi { ...headers }); } catch (e) { - const err = e as AxiosError; - if (err.response && err.response.status === 401) { + const err = e as ErrorFiltered; + if (err?.status === 401) { log.debug('Requesting new token from prices.tf due to 401'); await this.setupToken(); return this.authedApiRequest(httpMethod, path, params, data, headers); @@ -123,16 +123,12 @@ export default class PricesTfApi { } async setupToken(): Promise { - return new Promise((resolve, reject) => { - void PricesTfApi.requestAuthAccess() - .then(response => { - this.token = response.accessToken; - resolve(); - }) - .catch(err => { - reject(err); - }); - }); + try { + const r = await PricesTfApi.requestAuthAccess(); + this.token = r.accessToken; + } catch (e) { + log.error(e as Error); + } } async requestCheck(sku: string): Promise {