johnpapa / lite-server

Lightweight node server
MIT License
2.31k stars 267 forks source link

I am trying to use Buffer.From but lite-server return that it's udefined #163

Closed yehia67 closed 5 years ago

yehia67 commented 5 years ago

How to make lite-server use "Buffer.from"

my code:

ipfs.add([Buffer.from(JSON.stringify(userJson))], function(err, res) {
 if (err) throw err
 ipfsHash = res[0].hash
console.log(‘creating user on eth for’, username, title, intro, ipfsHash);
User.deployed().then(function(contractInstance) {
 // contractInstance.createUser(web3.fromAscii(username), web3.fromAscii(title), intro, ipfsHash, {gas: 2000000, from: web3.eth.accounts[0]}).then(function(index) {
 contractInstance.createUser(username, ipfsHash, {gas: 200000, from: web3.eth.accounts[0]}).then(function(success) {
 if(success) {
 console.log(‘created user on ethereum!’);
 } else {
 console.log(‘error creating user on ethereum’);
 }