Getting response empty when first time calling the couch node rest api

91 Views Asked by At

Getting the empty response when the node api hitting first time even though the data is available in couchbase, When hitting the second time it works fine.

This is my api for getting the data:

app.get('/api/store/findByAccNo/:accountNumber',function(req,res) {
        storeMdl.findByAccountNumber(req.params.accountNumber,function(err,data){
            if (data=="") {
                var message = JSON.parse('{"status":"Failed","message":"Store does not exist"}');
                res.send(200, message);
            } else{
                var message = JSON.parse('{"status":"Success","message":' + JSON.stringify(data) + '}');
                res.send(message) 
            } 
        });

    });

If I am doing any thing wrong please help me to solve this.

Thanks

0

There are 0 best solutions below