You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Sync Call using Database API

Received Response
5
Views
3
Comments
edited Sep 8, 2017 7:00AM in Digital Assistant and Mobile 3 comments

Summary

Sync Call using Database API

Content

Hi,

I have a flow something like this. The issue is before the  req.oracleMobile.database.get finishes the response is returned. How can i wait till my db operation finishes then only return back from here.

module.exports = {        checkToken: function (req, res, loggingFlag) {        var result = {            "statusCode": 401,            "success": false,            "message": "Generic Failed."        };        var token = req.body.tokens;        if (token) {            try {                var decoded = jwt.decode(token);                req.oracleMobile.database.get(                    'TABLES', decoded.userName,{sync: true}).then(                    function (result) {                        if (somecondition) {                            //somecode                        } else {                            //somecode                        }                    },                    function (error) {                        //error handler code                    }                );            } catch (err) {                result.statusCode = 403;                result.success = false;                result.message = "Failed to authenticate .";            }        } else {            result.statusCode = 403;            result.success = false;            result.message = "Error Provided.";        }        return result;    },};

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!