Santiago
Santiago

Reputation: 11

Zoho Catalyst Log Out

I am trying to create a webpage to be hosted on Zoho Catalyst. When attempting to create a log out, following the documentation, I receive the following error:

ReferenceError: Catalyst is not defined at logout.html:17:24

The code I have is as follows:

<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Cierre de Sesión</title>
</head>
<body>
    <table>
        <tr>
            <td><a class="boton" id="cerrar-sesion" href="#">Cerrar Sesión</a></td>
        </tr>
    </table>

    <script src="https://static.zohocdn.com/catalyst/sdk/js/4.0.0/catalystWebSDK.js"></script>
    <script>
        var catalyst = new Catalyst({
            projectID: 'project_ID',
            clientID: 'Client_ID',
            clientSecret: 'Client_Secret'
        });

        catalyst.init();

        function cerrarSesion(event) {
            event.preventDefault();
            var redirectURL = "https://redirect-url.com/baas/logout?logout=true&PROJECT_ID=my_project_ID";
";
            catalyst.auth.signOut(redirectURL)
            .then(function() {
                console.log("Sesión cerrada correctamente");
                window.location.href = redirectURL;
            })
            .catch(function(error) {
                console.error("Error al cerrar sesión:", error);
            });
        }

        document.addEventListener("DOMContentLoaded", function() {
            document.getElementById("cerrar-sesion").addEventListener("click", cerrarSesion);
        });
    </script>
</body>
</html>

What am I doing wrong?

I've even tried to correct with AI the error but it still the same every time I try to execute the code

Upvotes: 0

Views: 52

Answers (2)

Prabhu Raam Yogaraj
Prabhu Raam Yogaraj

Reputation: 691

To initialize your Catalyst project to the Catalyst Web SDK from your web application, you would need to add the below script tags in your HTML page

<script src="https://static.zohocdn.com/catalyst/sdk/js/4.4.0/catalystWebSDK.js"></script>
<script src="/__catalyst/sdk/init.js"></script>

To know more about Catalyst Web SDK, you can the help documentation here

Upvotes: 0

Shri Hari L
Shri Hari L

Reputation: 4913

This might be probably because of the line: new Catalyst() as we are trying to initialize the app.

From the docs, the only way to initialize the app is to include init.js from the Catalyst's reserved path.

<script src="/__catalyst/sdk/init.js"></script>

Upvotes: 1

Related Questions