测试跨域html

创建一个html文件,内容如下,如能正确访问并返回则说明服务器端跨域设置正确

<script>
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://192.168.62.110:8769/api-point/points');
xhr.setRequestHeader('content-type', 'application/json');

const json = {
  "groupId": "string",
  "keyword": "string",
  "max": 0,
  "min": 0,
  "page": 0,
  "size": 0
}

// send rquest with JSON payload
xhr.send(JSON.stringify(json));

xhr.onload = function(e) {
    var xhr = e.target;
    console.log(xhr.responseText);
}

</script>

json字符串可以直接从swagger-ui.html中copy最方便

 

posted @ 2020-05-21 15:08  Season2009  阅读(542)  评论(0编辑  收藏  举报