Here is contract:
pragma solidity ^0.4.17;
contract Demo{
string public data;
function Demo()public{
data = "Jiu Wei";
}
function getData() public view returns (string) {
return data;
}
}
Here is web3.js code:
var abi = /*abi*/
var address = "0x850e97f8692ffe27c867b1401244691736c021ee";
var myContractInstance = web3.eth.contract(abi).at(address);
myContractInstance.getData.call(function (result, error) {
if(!error) {
console.log(result);
}
});
The question is it returns null all the time.
What should I do for the code?
Please give me some advice on how to handle a situation like this. Thank you in advance.