1. 创建一个XMLHttpRequest对象
var xhr = new XMLHttpRequest();
  1. 设置请求方法和URL
xhr.open('GET', 'http://example.com', true);
  1. 设置请求头部
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Authorization', 'Bearer ' + token);
  1. 发送请求
xhr.send();
xhr模仿浏览器设置请求头部

原文地址: http://www.cveoy.top/t/topic/g8KE 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录