我正在使用此函数来调用REST请求,但是,每当我使用该按钮调用此函数时,我都会拒绝连接。我可以知道如何绕过这个问题吗?
function getContacts() {
var settings = {
"async": true,
"crossDomain": true,
"url": "http://localhost:5000/chaincode",
"method": "POST",
"headers": {
"cache-control": "no-cache",
"postman-token": "827ed81a-b8b4-d6a5-7e2c-e36f955b7423"
},
"data": "{\r\n \"jsonrpc\": \"2.0\",\r\n \"method\": \"query\",\r\n \"params\": {\r\n \"type\": 1,\r\n \"chaincodeID\":{\r\n \"name\":\"mycc\"\r\n },\r\n \"ctorMsg\": {\r\n \"function\":\"query\",\r\n \"args\":[\"a\"]\r\n }\r\n },\r\n \"id\": 1\r\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
}