Call js function in different js files

I have file formUtils.js (JS Query) with code:

// I will call this function in different places
const formUtils = {
    isFullNamesEqual: (name1, name2) => {
        console.log("Comparing names" , name1, " with ", name2);
        return name1.trim().toLowerCase() === name2.trim().toLowerCase();
    }
};
return formUtils;

test.js (JS Query ) has a code:

const myUtils = await formUtils.trigger();
myUtils.isFullNamesEqual("test1", "test2");

The code works fine, but if I open the browser console, I see the following error:

runtime.C8mYDWCe.umd.js:6 
Object not serializable. {type: 'UPDATE_NODE', payload: {…}}

Please tell me what the problem is? Can I ignore it since the code works?

I often see a bunch of errors and junk in the browser console in retool. I think you're fine.

1 Like

Hi @Vladyslav,

This code isn't working in my test app :thinking:

Without other context, I'd most likely refactor it to use additionalScope similar to this example:

Thank you. I will try your code. My original code is here:

1 Like

Let us know if you run into any blockers or questions!

Can you check code from my last message. Why I receive errors in console of browser?

Hi @Vladyslav_Semenov

I'm not sure why we're seeing different console logs and errors :thinking: With the code above, I get these two errors and nothing is logged.

In order to pass 'test1' and 'test1' to formUtils, you can remove them from line 2 in the test query and move them to additionalScope in the test query's .trigger():

Then, formUtils, can be refactored to return an object and also console log: