I am trying to create a new property using data hook. The function I have logs the results successfully but when I try to assigned the result of the function to the new object, it doesn’t work. it shows "totalCoaches":{"isFulfilled":false,"isRejected":false} I am not sure why. Would anyone know how to solve this please? Thanks!
import wixData from ‘wix-data’;
export function CoachingAreas_afterQuery(item, context) {
const findNumCoaches = (id) => {
return wixData.queryReferenced(“CoachingAreas”,id,“coachName”)
.then(result => {
let totalCoaches = result.totalCount;
console.log(totalCoaches);
return totalCoaches;
})
}
item.totalCoaches = findNumCoaches(item._id).then(result => result)
return item;
}