I am creating a rest api. My get method will return the result according to the total supply value of the contract or it will not respond, but the request I made to the contract returns a promise. How can I use this value?
const NameContract = new web3.eth.Contract(abi, '0xE3A2beCa..........1D901F8');
NameContract.methods.totalSupply().call().then(value => console.log(value))
app.get('/:id', (req, res) => {
let id = parseInt(req.params.id);
//I want to use an if here.
//I want to throw the query according to the value returned from above,
// but it returns a promise, how can I use it value?
nft.findOne({ id: id }, (err, doc) => {
if (doc != null) {
res.json(doc)
}
else {
res.status(404).json(err)
}
});
});