使用浏览器发送post请求 适用于内网 并且没有postman的情况下

谷歌浏览器 console 控制台输入 以下命令 允许复制

allow pasting

然后粘贴请求代码 示例:

var url = "https://icp.minexiot.com/prod-api/alarmInfo/page";
var params = {
    "page": 1,
    "limit": 10,
    "confirmStatus": 1
};
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("authorization", "Bearer eyJhbGciOiJIUzUxMiJ9.eyJ0ZW5hbnRfaWQiOjEsInV1aWQiOiI4ODExMzg1YTRkYTI0YjEwYmRiZTkzNmFkOTIzOGQ4ZSJ9.RDHBj18pAedVLXaqKxx57kfAtBE6MglgO_qHuH41Kuimb5XTq2Jg0WqUa0MhPzYaD2Y8hRIAGcYSK3TKeev_Ew");
xhr.onload = function (e) {
  if (xhr.readyState === 4) {
    if (xhr.status === 200) {
      console.log(xhr.responseText);
    } else {
      console.error(xhr.statusText);
    }
  }
};
xhr.onerror = function (e) {
  console.error(xhr.statusText);
};
xhr.send(JSON.stringify(params));

 

 

posted @ 2024-08-30 18:24  官萧何  阅读(242)  评论(0编辑  收藏  举报