【问题标题】:Unable to run the multichain-node (npm module) in client side(browser)无法在客户端(浏览器)中运行多链节点(npm 模块)
【发布时间】:2017-09-27 06:44:41
【问题描述】:
let multichain = require("multichain-node")({
    port: 6001,
    host:'localhost',
    user:'myuser',
    pass:'mypassword'
    });

    multichain.getInfo((error,info) => {
    if(error){
    throw error;
    }
    console.log(info);
    })
output:version: '1.0',
  nodeversion: 10000901,
  protocolversion: 10008,
  chainname: 'chain1',
  description: 'chain1',
  protocol: 'multichain',
  port: 6001,
  setupblocks: 60,
  nodeaddress: 'mulmul@localhost:6001',
  burnaddress: '1XXXXXXWh4XXXXXXXyXXXXXXZdXXXXXXYjGhfn',
  incomingpaused: false,
  miningpaused: false,
  walletversion: 60000,
  balance: 0,
  walletdbversion: 2,
  reindex: false,
  blocks: 127,
  timeoffset: 0,
  connections: 0,
  proxy: '',
  difficulty: 6e-8,
  testnet: false,
  keypoololdest: 1506490805,
  keypoolsize: 2,
  paytxfee: 0,
  relayfee: 0,
  errors: '' }

此输出显示在命令提示符中,我如何在浏览器中执行此代码

【问题讨论】:

  • 你想做什么,这段代码不适合浏览器而且在我看来,多链只适用于服务器

标签: javascript c# node.js


【解决方案1】:

multichain-node 是一个节点模块;在浏览器中运行是没有意义的。

特别是它使用节点的http模块来发出http请求;如果您想在浏览器中执行此操作,您需要使用 fetch 或 XMLHttpRequest 执行此操作,并且您需要正确设置 CORS。

【讨论】:

  • 怎么获取,能否详细解释一下
  • 使用browserify捆绑所有js文件,并在浏览器上运行,然后我得到ERR_EMPTY_RESPONSE
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-06-26
  • 1970-01-01
  • 1970-01-01
  • 2021-08-20
  • 2011-10-02
  • 2016-06-10
  • 1970-01-01
相关资源
最近更新 更多