Uncaught (in promise) ReferenceError: store is not defined

caroline
caroline Member

Hi, I'm having an issue with the Daily API. Would love some help!

When I call callObject.setUserData()I receive the following console error:

Uncaught (in promise) ReferenceError: store is not defined

Is there any way to check whether store exists before calling callObject.setUserData? or another way to check that callObject.setUserData is available to use?

The line in my code that's causing the error is as follows:

useEffect(() => {

(async () => {

if (user?.uuid && callObject) {

const userData = await getCurrentUser();

callObject.setUserData({

connectionId: connectionId,

userName: userData?.username ? userData?.username : "",

displayName: userData?.name ? userData?.name : "",

profilePic: userData?.profilePic ? userData?.profilePic : "",

userId: userData?.uuid ? userData?.uuid : "",

});

})();

}, [user, callObject]);


Attaching a photo of the full error trace. AV.tsx:81 is the line where I call callObject.setUserData, and commenting that line out removes the errors. Through tracing the code in the daily API, it seems as though there is some store variable that does not exist when I make this call.


Answers

  • daily_joey
    daily_joey Moderator, Dailynista admin

    Hi @caroline , I believe you can only use setUserData() while you are actively in a session. Can you share more information about when you are attempting to update the user data? Is it before or after the joined-meeting event?

  • caroline
    caroline Member
    edited March 2023

    Hi @daily_joey – Ahh, I was treating callObject not null as an indication that the meeting was joined. What is the syntax to listen for the joined-meeting event?

  • daily_joey
    daily_joey Moderator, Dailynista admin

    @caroline you should be able to add a listener for the joined-meeting event like shown in our docs:

    callFrame
      .on('joined-meeting', (event) => {
        console.log('joined-meeting event', event);
        // now in a meeting, update user data, etc.
      });