From 1f6ec9d2f02aa44072931c26bd2aad2200afc824 Mon Sep 17 00:00:00 2001 From: Sebastian Rindom Date: Thu, 3 Sep 2020 10:31:43 +0200 Subject: [PATCH] fix: send response --- .../src/api/index.js | 2 +- .../utils/brightpearl.js | 29 +++++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/packages/medusa-plugin-brightpearl/src/api/index.js b/packages/medusa-plugin-brightpearl/src/api/index.js index 8749f0da17..ce12232710 100644 --- a/packages/medusa-plugin-brightpearl/src/api/index.js +++ b/packages/medusa-plugin-brightpearl/src/api/index.js @@ -66,7 +66,7 @@ export default (container) => { } await brightpearlService.createSalesOrder(order) - res.status(200) + res.sendStatus(200) } catch (err) { res.status(400).json(err) } diff --git a/packages/medusa-plugin-brightpearl/utils/brightpearl.js b/packages/medusa-plugin-brightpearl/utils/brightpearl.js index ded96e3cfb..1056f7cc40 100644 --- a/packages/medusa-plugin-brightpearl/utils/brightpearl.js +++ b/packages/medusa-plugin-brightpearl/utils/brightpearl.js @@ -355,47 +355,44 @@ var BrightpearlClient = /*#__PURE__*/function () { switch (_context.prev = _context.next) { case 0: response = error.response; - console.log(response.data && response.data.errors); if (!response) { - _context.next = 15; + _context.next = 13; break; } if (!(response.status === 401 && error.config && !error.config.__isRetryRequest)) { - _context.next = 15; + _context.next = 13; break; } - _context.prev = 4; - _context.next = 7; + _context.prev = 3; + _context.next = 6; return onRefresh(_this2); - case 7: - _context.next = 13; + case 6: + _context.next = 11; break; - case 9: - _context.prev = 9; - _context.t0 = _context["catch"](4); - console.log(_context.t0); // refreshing has failed, but report the original error, i.e. 401 - + case 8: + _context.prev = 8; + _context.t0 = _context["catch"](3); return _context.abrupt("return", Promise.reject(error)); - case 13: + case 11: // retry the original request error.config.__isRetryRequest = true; return _context.abrupt("return", _this2.client_(error.config)); - case 15: + case 13: return _context.abrupt("return", Promise.reject(error)); - case 16: + case 14: case "end": return _context.stop(); } } - }, _callee, null, [[4, 9]]); + }, _callee, null, [[3, 8]]); })); return function (_x) {