休息请求
POST host:port/chaincode
{
"jsonrpc": "2.0",
"method": "deploy",
"params": {
"type": 1,
"chaincodeID":{
"path":"github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
},
"ctorMsg": {
"function":"init",
"args":["a", "1000", "b", "2000"]
}
},
"id": 1
}
休息反应
{
"jsonrpc": "2.0",
"result": {
"status": "OK",
"message": "52b0d803fc395b5e34d8d4a7cd69fb6aa00099b8fabed83504ac1c5d61a425aca5b3ad3bf96643ea4fdaac132c417c37b00f88fa800de7ece387d008a76d3586"
},
"id": 1
}
我有这组请求和响应,他们提到接口端口是5000。我如何调用这个休息请求并提醒响应结果?我试过jquery,但我做不到。他们一直提示我窗口错误。
这是我尝试过的
$.post('localhost:5000/chaincode', {
"jsonrpc": "2.0",
"method": "deploy",
"params": {
"type": 1,
"chaincodeID": {
"path": "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02"
},
"ctorMsg": {
"function": "init",
"args": ["a", "1000", "b", "2000"]
}
},
"id": 1
}, function (serverResponse) {
alert(serverResponse);
//do what you want with server response
})