I am new to WIX and I can’t seem to get basic things working.
All I want to figure out right now is how to take input from 3 fields and add it to the Collection. I have a dataset for the aircraft list.
Issues:
-
Aircraft list does not populate in the dropdown. It does when I do page preview though.
-
Nothing happens when I click the button. No records are inserted.
-
I also notice that nothing goes to the Console Log when I try Preview the page.
Here is my code. What am I doing wrong?
import wixData from ‘wix-data’ ;
$w( “#button3” ).onClick(insertFlight)
export function insertFlight(event, $w){
let flight = {
“Origin” : $w( “#originICAO” ).value,
“Destination” : $w( “#destinationICAO” ).value,
“Aircraft” : $w( “#aircraft” ).value
};
console.log( “Flight to be saved” + JSON.stringify(flight));
wixData.insert( “PlannedFlights” , flight)
.then( (results) => {
flight = results; //see item below
console.log( "Flight in db: " + JSON.stringify(flight));
} )
. catch ( (err) => {
let errorMsg = err;
} );
}