Hi everyone,
I’m using wixData.insert to put information into a couple of databases from a custom form. The data is added to both databases as expected, however the item doesn’t seem to be returning in the .then() promise. The ‘results’ variable is undefined. Any help would be greatly appreciated.
Here’s my code.
let properties_toInsert = {
“title”: local.getItem(“place_name”),
“formattedAddress”: formatted_address,
“latitude”: latitude,
“longitude”: longitude,
“numberOfBedrooms”: numberOfBedrooms,
“numberOfBathrooms”: numberOfBathrooms,
“googleId”: googleId
};
let ratings_toInsert = {
“transportRating”: transportRating,
“landlordRating”: landlordRating,
“socialSpaceRating”: socialRating,
“locationRating”: locationRating,
“priceRating”: priceRating,
“yearOfOccupancy”: occupationYear,
“yearOfStudy”: yearOfStudy,
“tenant”: tenantName,
“tenantEmail”: tenantEmail,
“comment”: comment
};
wixData.insert("properties", properties_toInsert)
.then( (results) => {
let item = results; //see item below
newPropertyId = results._id;
})
. catch ( (err) => {
let errorMsg = err;
});
wixData.insert("ratings", ratings_toInsert)
.then( (results) => {
let item = results;
newRatingId = results._id;
})
. catch ( (err) => {
let errorMsg = err;
});