Hello everyone,
please have a quick look at following code. I think I do not have to explain it.
…
let user_data = {
lotNumber : 0 ,
name : “Meyer” ,
surname : “Hans” ,
street : “Straße” ,
houseNumber : “1” ,
postalCode : 11111 ,
city : “Stadt”
};
wixData . query ( “database_lots” )
. count ()
. then (( num ) => {
let start_id = num ; //= 52
**for** ( let i = 0 ; i < 2 ; i ++) {
user_data [ "lotNumber" ] = start_id ;
console . log ( start_id + " : " + user_data [ "lotNumber" ]);
console . log ( user_data );
start_id ++;
}
})
. catch (( error ) => {
let errorMsg = error . message ;
let code = error . code ;
console . log ( errorMsg );
});
…
When I run this code snippet it will prompt the following:
Seems to look exactly like what I want. But wait… when I am opening the dictionary to look into it the variable “lotNumber” suddenly has a different value.
Maybe I am blinded of my own code but I do not get it.
Can you help?