Log error

This commit is contained in:
Sebastian Rindom
2020-08-23 17:30:12 +02:00
parent d0df896ea4
commit aed9feb357
2 changed files with 11 additions and 1 deletions

View File

@@ -93,6 +93,7 @@ class BrightpearlClient {
this.client_.interceptors.response.use(undefined, async (error) => {
const response = error.response
console.log(response)
if (response) {
if (

View File

@@ -7,6 +7,8 @@ exports["default"] = void 0;
var _axios = _interopRequireDefault(require("axios"));
var _axiosRateLimit = _interopRequireDefault(require("axios-rate-limit"));
var _querystring = _interopRequireDefault(require("querystring"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -25,6 +27,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// Brightpearl allows 200 requests per minute
var RATE_LIMIT_REQUESTS = 200;
var RATE_LIMIT_INTERVAL = 60 * 1000;
var BrightpearlClient = /*#__PURE__*/function () {
_createClass(BrightpearlClient, null, [{
key: "createToken",
@@ -282,12 +288,15 @@ var BrightpearlClient = /*#__PURE__*/function () {
};
});
this.client_ = _axios["default"].create({
this.client_ = (0, _axiosRateLimit["default"])(_axios["default"].create({
baseURL: "https://".concat(options.url, "/public-api/").concat(options.account),
headers: {
"brightpearl-app-ref": "medusa-dev",
"brightpearl-dev-ref": "sebrindom"
}
}), {
maxRequests: RATE_LIMIT_REQUESTS,
perMilliseconds: RATE_LIMIT_INTERVAL
});
this.authType_ = options.auth_type;
this.token_ = options.access_token;