This is my async function:
const returnNumberOfFoods = async() => {
const web3 = new Web3(url);
// const networkId = await web3.eth.net.getId();
const myContract = new web3.eth.Contract(
Contract.abi,
Contract.address
);
let result;
await myContract.methods.numberOfFoods().call(function(err, res) {
result = res;
});
return result;
}
And this is how I am trying to get value:
const numberOfCardsPromise = returnNumberOfFoods();
const numberOfCards = numberOfCardsPromise.then(value => { return value; });
console.log(numberOfCards);
But this is what I get in console:
Promise {<pending>}
[[Prototype]]: Promise
[[PromiseState]]: "fulfilled"
[[PromiseResult]]: "4"
The PromiseResult
is my desired output.