Return json/array form a method in app.js

Hello everyone, i have an issue with dumping out json in a function in another component page from a app.js methods.

ListRiders() Is a function that is supposed to list all the riders connected to a certain channel on pubnub and pour out the json, but the issue it displays undefined in the user page, but in the rider page it pours json just fine.

APP.JS FUNCTION

listRiders: function () {

      pubnub.hereNow(

        {

            channels: ["gz_rider_status_channel"], 

            // channelGroups : ["cg1"],

            includeUUIDs: true,

            includeState: true 

        },

        function (status, response) {

            // handle status, response

            console.log("STATUS: " + status.error);

            console.log("RESPONSE CHANNELS: " + response.totalChannels);

            console.log("RESPONSE OCCUPANCY: " + response.totalOccupancy);

            liveRiders = response.channels.gz_rider_status_channel.occupants;

            console.log( "LIVE RIDERS FUNCTION: " + JSON.stringify(liveRiders) );

            return JSON.stringify(liveRiders);

        });

    },

USERS-RIDER-SEARCH.HTML

const uuid = window.PubNub.generateUUID();

                let my_info = [];

                my_info["user"] = "user";

                my_info["name"] = window.localStorage.getItem("user-name");

                my_info["email"] = window.localStorage.getItem("user-email");

                my_info["phone"] = window.localStorage.getItem("user-phone");

                my_info["longitude"] = window.localStorage.getItem("user-longitude");

                my_info["latitude"] = window.localStorage.getItem("user-latitude");

                                                

                window.app.methods.riderIsOnline();

                window.app.methods.addPresenceUser(uuid, my_info);

                setInterval(() => {

                    liveRiders = app.methods.listRiders();

                    console.log( liveRiders ); // undefined

                    $.each( liveRiders, function( key, value ) {

                        console.log("Riders are avaiable!!!");

                    });

                }, 2000);

Hi there,
i don’t think you have a ‘app’ variable defined. Either define it or use the global window.app