Hook afterInsert for collection MyCollectionName result ignored! Expected hook result to resolve to an object with an ‘_id’ property, but got [Undefined]
I’m able to dump the item and the context to the console and the information is there, including the so-called undefined ‘_id’ property.
Right now it appears that hooks are unreliable and they have to be coded elsewhere (over and over again).
I was having the same problem when I tried to save data to more than one database, but then I realized I left out the ‘let’ and ‘return’ statements. So the function must include them, or at least the ‘return’ statement:
export function myCollection_afterInsert(item, context) {
let hookContext = context;
// here goes whatever action you want to run, between ‘let’ and ‘return’
return item; //so the item value is returned to the function caller
}