trouble with bulkSave()

Reloading a page using bulksave() doubles the number of items saved to the collection, does anyone know why?

where is the code for that currious behaviour ???

hi, Velo-Ninja!! thank you always for your help!!

velo API’s sample code of bulkSave() below (maybe any other code will do same )

let toSave1 = {
“title” : “Mr.” ,
“first_name” : “John” ,
“last_name” : “Doe”
};

let toSave2 = {
“title” : “Ms.” ,
“first_name” : “Jane” ,
“last_name” : “Doe”
};

wixData . bulkSave ( “collectionName” , [ toSave1 , toSave2 ])
. then (( results ) => {
let inserted = results . inserted ; // 2
let insertedIds = results . insertedItemIds ; // see below
let updated = results . updated ; // 0
let skipped = results . skipped ; // 0
let errors = results . errors ; // []

console.log(inserted); // 2 (this log always prints correctly but…)

})
. catch (( err ) => {
let errorMsg = err ;
});

when I reload the page, the number of items in the collection increases by 4.

why???

Now, I tried " wixWindow . rendering . env"
then the bulkSaving behavior becomes correct(items in the collection increases by 2.).

if ( wixWindow . rendering . env === “browser” ) {
wixData.bulkSave()…
}

bulkSave() in frontend code needs " wixWindow . rendering . env" to avoid server side rendering ???