0
我试图把这种终点:https://blockchain.info/rawtx/$tx_hash
以下列方式使用请求响应模块:使用参数在节点中获取请求的最佳做法是什么?
api.get('/transaction/:hash', (req, res) => {
const hash = (req.params.hash);
let uri = 'https://blockchain.info/rawtx/' + hash;
rp(uri).then(function (txInfo) {
let result = JSON.parse(txInfo);
}
有呼叫终点,而不是仅仅串联的说法更清洁的方式吗?
可以使用字符串模板:'let uri = \'https://blockchain.info/rawtx/$ {req.params.hash} \''' – tymeJV