cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5: Issue with SecuredExecution method.

former_member611643
Participant
0 Kudos
341

Hi Gurus,

I need to read data from UserEntity, but I have to use SecuredExecuton method.

I have the following code right now, but it doesn't work, or rather, for some unknown reason, I get 4 then 1 in the console.

I can't figure out why I am facing catch first and then success.

Would be grateful for any feedback/comments.

Thanks.

this.extensionAPI.securedExecution(this._myFunction(UserID))
.then((oData) => {
       console.log(3);
})
.catch((oError) => {
       console.log(4);
});

_myFunction: function (UserID) {
    var sPath = ${Constants.UserEntity}('${UserID}');
    return new Promise((fnResolve, fnReject) => {
        this.getView().getModel().read(sPath, {
            urlParameters: {
                $select: Constants.USER_ID_PROPERTY
            },
            success: (oData) => {
                console.log(1);
                fnResolve(oData);
            },
            error: (oError) => {
                console.log(2);
                fnReject(oError);
            }
        });
    });
}

Accepted Solutions (0)

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos
securedExecution need function as first parameter. you are doing a function call and the returned promise is passed to the securedExecution as first parameter