Skip to content

How to run bitcoin-node-api example ? #2

@Smurfy303

Description

@Smurfy303

When I am trying to run below example as

var bitcoinapi = require('bitcoin-node-api');
var express = require('express');
var app = express();

var wallet = {
  host: 'localhost',
  port: 8332,
  user: 'username',
  pass: 'password'
};
bitcoinapi.setWalletDetails(wallet);
app.use('/bitcoin/api', bitcoinapi.app); //Bind the middleware to any chosen url

app.get('/getApi' , (req,res) => {

	var url = 'http://localhost:3000/bitcoin/api/getinfo';
	console.log('Url is :->',url);

	var request = require('request');
	request(url, function (error, response, body) {
		console.log('response-->',response);
		console.log('Error-->',error);
		
	  if (!error && response.statusCode == 200) {
	  	//var response = JSON.parse(body);
	    res.send(response); 
	  }
	  else { 
	    console.log("Error "+error);
	  }
	});
})
app.listen(3000,(port)=>{
	console.log('Port at 3000');
});

and trying to run : node app.js it giving me an error as,

{ Error: connect ECONNREFUSED 127.0.0.1:8332
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8332 }

can you please tell me how to run bitcoin-node-api ??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions