how do i pull an email from wix into a data base...my code below looks okay but not sure why no love

// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import wixUsers from ‘wix-users’;

import wixData from ‘wix-data’;

import wixLocation from ‘wix-location’;

$w.onReady( function () {

let user = wixUsers.currentUser;

let userId = user.id; // “r5cme-6fem-485j-djre-4844c49”

let isLoggedIn = user.loggedIn; // true

        user.getEmail() 

            .then((email) => { 

let userEmail = email;
$w(“#emailthree”).text = userEmail;

            }); 

        $w("#button1").onClick(() => { 

let toInsert = {

“email”: $w(“#emailthree”).text,
}

                }) 

})

import wixUsers from ‘wix-users’;

$w.onReady( function () {

//check if the user is logged in, if they are then proceed to get their details

if (wixUsers.currentUser.loggedIn) {

let user = wixUsers.currentUser;

console.log(user);

    user.getEmail() 

        .then((email) => { 

let userEmail = email;

console.log(userEmail);

        }) 

}
})

import wixUsers from “wix-users”;
import wixData from ‘wix-data’;

$w.onReady( function () {

//place a post comment button on the page and call it commentButton1

$w('#commentButton1').onClick( **function**  () { 

//dataset1 is connected to your collection where you store the original post

let orininalPostId = $item(“#dataset1”).getCurrentItem()._id;

//dataset2 is connected to your collection where you store the comments, make sure you have set read/write access to dataset2

    $w("#dataset2").onReady(() => { 

let user = wixUsers.currentUser;

//get userEmail so that it can be passed to the comments database that way we know who made the comment

        user.getEmail() 

            .then((email) => { 

let currentUserEmail = email;

//create columns in your comments database and name them orininalPostId, comment, userEmail. Place an comment input box on the page and call it commentInputBox1

//now we save the comment to the database

                $w('#dataset2').setFieldValue('orininalPostId', (orininalPostId)); 
                $w('#dataset2').setFieldValue('comment', $w('#commentInputBox1').value); 
                $w('#dataset2').setFieldValue('userEmail', (currentUserEmail)); 
                $w('#dataset2').save() 

            }) 
    }) 
}) 

})

firstly bro…thanks for such a detail description… i tried dumbing it down by removing the get dataset1 info, but when i click the button, nothing happens. i would have though at the very least when i clicked it, the user email and comment would go into dataset two

import wixUsers from “wix-users”;
import wixData from ‘wix-data’;

$w.onReady( function () {

//place a post comment button on the page and call it commentButton1

$w('#commentButton1').onClick( **function**  () { 

//dataset1 is connected to your collection where you store the original post

//let orininalPostId = $item(“#dataset1”).getCurrentItem()._id;

//dataset2 is connected to your collection where you store the comments, make sure you have set read/write access to dataset2

    $w("#dataset2").onReady(() => { 

let user = wixUsers.currentUser;

//get userEmail so that it can be passed to the comments database that way we know who made the comment

        user.getEmail() 

            .then((email) => { 

let currentUserEmail = email;

//create columns in your comments database and name them orininalPostId, comment, userEmail. Place an comment input box on the page and call it commentInputBox1

//now we save the comment to the database

// $w(‘#dataset2’).setFieldValue(‘orininalPostId’, (orininalPostId));
$w(‘#dataset2’).setFieldValue(‘comment’, $w(‘#commentInputBox1’).value);
$w(‘#dataset2’).setFieldValue(‘useremail’, (currentUserEmail));
$w(‘#dataset2’).save()

            }) 
    }) 
}) 

})

Try this
using async/await

import wixUsers from 'wix-users';
$w.onReady(async ()=>{
    //Using await to get the email in the same line
    let email = await wixUsers.currentUser.getEmail();
    // Code will be trigger when the dataset is saving 
    $w('#dataset1').onBeforeSave(()=>{
        //Storing the email on the dataset during the saving
        $w('#dataset1').setFieldValue("fieldKey", email)
    });
})