拦截ajax

版权声明:三和小钢炮 https://blog.csdn.net/fwx426328/article/details/83758248

拦截ajax

(function (open) {
  XMLHttpRequest.prototype.open = function () {
    let args = arguments;
    this.addEventListener('readystatechange', function () {
      if (this.readyState === 4) {
        console.log(args);
      }
    }, false);
    open.apply(this, args);
    this.setRequestHeader('Authorization', 'Token 123');
  };
})(XMLHttpRequest.prototype.open);

猜你喜欢

转载自blog.csdn.net/fwx426328/article/details/83758248