From 7e0808e631f5d6dd068439bbacd9bc089a99dcc6 Mon Sep 17 00:00:00 2001 From: Noobgam Date: Sat, 6 Apr 2024 23:26:50 +0200 Subject: [PATCH] fix: notify session expired on 403 --- lib/webapi.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/webapi.js b/lib/webapi.js index 8880bf4..cb47972 100644 --- a/lib/webapi.js +++ b/lib/webapi.js @@ -36,16 +36,13 @@ TradeOfferManager.prototype._apiCall = function(httpMethod, method, version, inp options[httpMethod == 'GET' ? 'qs' : 'form'] = input; this._community.httpRequest(options, (err, response, body) => { - if (err) { - err.body = body; - callback(err); - return; - } - - var error; + var error = err; - if (response.statusCode != 200) { + if (response.statusCode != 200 && !error) { error = new Error('HTTP error ' + response.statusCode); + } + + if (error) { error.body = body; if (typeof response.body === 'string' && response.body.indexOf('Access is denied') >= 0) {