I am using an afterInsert hook to send a message after an item is inserted to a collection. The hook works fine when a form is filled out on another local page on the site.
The problem occurs when the hook runs after an item is inserted with an http-function in the backend. The item is inserted into the collection, but the afterInsert hook fails.
Errors received:
"Hook afterInsert for collection MyCollection result ignored! Expected hook result to resolve to an object with an '_id' property, but got [Undefined]"
"afterInsert Error","WDE0002: ItemId must be a string."
When I console.log the item, it has a string id. But if I log the id, it’s undefined:
"item.id: undefined"
"item._id: 08d90f32-fc7f-4d20-a6b7-c8b9292e089f"
Appreciate any help!