I am making a contract with a front-end made with JS, I studied myself how to make it work calling the functions with or without variables. But I don't know how to get the return value. I would appreciate your help. On Remix it works fine. The solidity function of the issue
function Recompte() public returns (uint _votes, string memory _info){
if (estat == true) {
return (votes,"Poll stills on");
}else{
for (uint i = 0; i<candidats.length; i++){
if (candidats[i].votes > votes){
votes = candidats[i].votes;
idwinner = candidats[i].id;
}
}
}
return (idwinner, candidats[idwinner].name);
}
Code of JavaScript for this function for the moment
$("#fer_recompte").click(function(){
var val = 0;
val = parseInt($("#value_input").val());
console.log(val);
window.ethereum.enable();
web3.eth.getAccounts().then(function(accounts) {
var acc = accounts[0];
console.log(acc);
return contract.methods.Recompte().send({from: acc});
})
})
Sorry for making a mess, enters don't work and I don't know why JavaScript isn't inserted well.
Thank you for your time
Recompte()and you want the values returned. – Ismael Mar 20 '20 at 18:15