axios protobuf 通讯
2021-12-23 本文已影响0人
yaoyilmm
let obj = 'sssssss'
let data = {
address: '0xb3c734cECCf6eE67',
signature:'obj',
message:'I am signing my :'
}
let req = protoRoot.lookup("VerifySignatureReq").encode(data);
console.log("encode===" + req.finish().length);
let blob = new Blob([req.finish()], {type: 'buffer'});
axios.post('/api/login/verifySignature', blob,{headers: {
'Content-Type': 'application/x-jprotobuf;charset=UTF-8'
}}).then(function(response) {
console.log(response.data);
console.log(response.status);
console.log(response.statusText);
console.log(response.headers);
console.log(response.config);
});
}
}