How to return multiple values from back end function?

I am trying to return multiple values from backend function and getting error.

Following code is in TVerify1 page.

import {Testverify} from ‘backend/Test’;
$w.onReady( function () {
console.log(“TVerify page started”)
let [T1, T2, T3] = Testverify();
console.log(T1, T2, T3)
});

Following code is in backend/Test file. Test file is a jsw file.
export function Testverify () {
let t1, t2, t3; /
let T1;
console.log(“Test Verify function called”)
t1 = “White”;
t2 = “Blue”;
t3 = “Green”;
T1 = “Yellow”;
console.log(t1, t2, T1)
return [t1, t2, t3];
}
Here I am just trying to pass values White, Blue and Green to the TVerify1 page.
I am getting following error. Please help to get this fixed.
TypeError: Invalid attempt to destructure non-iterable instance
Thanks.

Is there anyone who can help on the above problem?

Not sure of what you are trying to do but this is how you pass multiple values from Backend to the page.

//fileName.jsw

export function myFunction() {
 let data = {
        name: 'Jessica',
        age: 25,
        occupation: 'Merchant'
    };
 return data;
}

Page Code:

import {myFunction} from 'backend/fileName'; //import the backend function

$w.onReady(function () {

});

export function button1_click(event) {
    myFunction() //run the backend function
    .then( (response) => {
        console.log(response); //your data is here
    });
}
1 Like

Thank you Shan. It helps.