Hi everyone !!!
Basically, I am having an array called 'Recipients'.
let Recipients = [];
In the next step, I query my database and get all the items in the field 'email'
wixData.query("Subscribers")
.isNotEmpty("email")
.find()
.then((res) => {
let items = res.items;
for (var i = 0; i < res.items.length; i++) {
var arr = items[i].email;
}
});
After these steps, all I want to add the 'arr' to the 'Recipients' array but, like this form ->
Recipients = [
{
"key": "value"
},
{
"key": "value"
},
{
"key": "value"
}
];
Any idea how to achieve this ??
Thanks !!!
Found the answer itself (Brain started working)
var Recipients = []; wixData.query("Subscribers") .isNotEmpty("email") .find() .then((res) => { let items = res.items; for (var i = 0; i < res.items.length; i++) { var obj = {}; var results = items[i].email; obj['key'] = results; Recipients.push(obj); } });
I think the basic code is ->
let Recipients = []; Recipients.push({"key" : "value"});