问题描述
我如何发送链下http发帖请求并获取哈希?
fn fetch(verify: T::Hash,number: Vec<u8>) -> Result<Vec<u8>,&'static str> {
let http_remote: &str = "http://localhost:3000/endpoint";
let pending = rt_offchain::http::Request::post(http_remote,verify)
.send()
.map_err(|_| "Error in sending http post request")?;
let response = pending.wait()
.map_err(|_| "Error in waiting http response back")?;
if response.code != 200 {
debug::warn!("Unexpected status code: {}",response.code);
return Err("Non-200 status code returned from http request");
}
Ok(response.body().collect::<Vec<u8>>())
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)