DefualtRequest.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = function (d, b) {
  3. extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return extendStatics(d, b);
  7. };
  8. return function (d, b) {
  9. extendStatics(d, b);
  10. function __() { this.constructor = d; }
  11. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12. };
  13. })();
  14. var __assign = (this && this.__assign) || function () {
  15. __assign = Object.assign || function(t) {
  16. for (var s, i = 1, n = arguments.length; i < n; i++) {
  17. s = arguments[i];
  18. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  19. t[p] = s[p];
  20. }
  21. return t;
  22. };
  23. return __assign.apply(this, arguments);
  24. };
  25. import { Request } from "./wx-request/index";
  26. import { RequestMethod, ResponseType } from "./wx-request/model";
  27. /**
  28. * 生成默认请求库
  29. *
  30. * @export
  31. * @class DefaultRequest
  32. */
  33. var DefaultRequest = /** @class */ (function (_super) {
  34. __extends(DefaultRequest, _super);
  35. function DefaultRequest(config, logger) {
  36. var _this = _super.call(this) || this;
  37. _this.logger = logger
  38. ? logger
  39. : {
  40. log: function (logLevel, message) {
  41. /* 屏蔽打印 */
  42. }
  43. };
  44. // default config
  45. _this.setConfig(__assign({ about: false, forceEnableHttps: false, headers: {}, method: RequestMethod.GET, responseEncoding: ResponseType.JSON, timeout: 2 * 60 * 1000, transformRequest: [], transformResponse: [] }, config));
  46. return _this;
  47. }
  48. return DefaultRequest;
  49. }(Request));
  50. export default DefaultRequest;