This is the update of my question:
This is my dynamic page “Users (ID)”:
And here is the code:
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixlocation from 'wix-location';// For full API documentation, including code examples, visit http://wix.to/94BuAAs
$w.onReady(function () {
$w('#button3').onClick(function () { //#button3 is SUBMIT button ID
let username = $w('#username').value;
let email = $w('#email').value;
let age = $w('#age').value;
let eyecolor = $w('#eyecolor').value;
let height = $w('#height').value;
let weight = $w('#weight').value;
let otherinfo = $w('#otherinfo').value;
let userInfo = {
"username": username,
"email": email,
"age": age,
"eyeColor": eyecolor,
"height": height,
"weight": weight,
"additionalInformation": otherinfo,
};
wixData.save("Users", userInfo)
.then( (results) => {
let userItem = results;
if($w("#uploadButton2").value.length > 0) {
let image = $w("#uploadButton2").value;
let userImage = {
"image": image,
"userId": userItem['_id'],
};
wixData.insert("UserImages", userImage)
.then(() =>{
wixlocation.to('/Users/${wixUsers.currentUser.id}')
})
}
} )
.catch( (err) => {
let errorMsg = err;
} );
})
});
But this code doesn’t work. Nothing is inserted/updated in the database collections!
`I hope someone can now tell me where are my errors in the code/structure!
