Skip to main content

call to smart contract function from express project using web3

hi i'm trying to create a API fo my smart contract functions like following

router.get('/',function (req,res) {
    var web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/key'));
    var DataPassContract = web3.eth.contract(abi);
    var dataPass = DataPassContract.at('contract address');

    dataPass.add('myaddress','a','a','a',{
        from: 'other address'
    }, (err, result) => {
        if (err) throw err;
        if (result) {
                res.send('yes');
            }
    });
});

when executed i want this function to open metamask and ask the client to confirm the transaction but when calling it i get this error

if (err) throw err; ^

Error: Invalid JSON RPC response: ""

any help would be appreciated