Understanding User Login API Specifications for Monaca Backend

Asked 2 years ago, Updated 2 years ago, 37 views

Using OnsenUI, Monaca backend API, you create an app that adds items to the backend collection when you press the button after logging in.

After logging in, I tried to get the OID of the user using monaca.cloud.User._oid, but it contains NULL.Will the login state not be maintained in the app after logging in?

monaca

2022-09-30 13:48

1 Answers

The login process is asynchronous, so if you try to retrieve it below .then(), you should be able to retrieve it.Present your own sample code.If you don't mind, please move it.It was created by editing a minimum template.

<!DOCTYPE HTML>
<html>
<head>
    <metacharset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scale=no">
    <script src="components/loader.js"></script>
    <link rel="stylesheet" href="components/loader.css">
    <link rel="stylesheet" href="css/style.css">
    <script>

        document.addEventListener('device ready', onDR, false);

        function onDR(){
            alert('device ready come!');
            monaca.cloud.User.login("hoge", "hogehoge")
                .then(function(){
                    alert(monaca.cloud.User._oid);
                });
        }
    </script>
</head>
<body>
</body>
</html>


2022-09-30 13:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.