Export data with data hooks and non-store databases

Hi All,

When I manually add a product into my database (a non-store product database), I’d like it to send over some data field info to a webhook listening on an automation platform.

To keep the testing simple and light, I’m focusing only on the data field.

Keep running into the error " Cannot read property ‘title’ of null " when I run the code. The “item.title” field not settling well and I can’t figure it out for the life of me.

Any help is appreciated. Below is the code I’m using for the data.js file.

import { fetch } from ‘wix-fetch’ ;

export function Items_afterInsert ( item , context ) {
let data = {
content : { item.title } //sends only the values of the title field
}
sendThe ( data );
}

function sendThe ( data ) {
const response = fetch ( “FancywebhookURL” , {
method : ‘POST’ ,
headers : {
“Content-Type” : “application/json”
},
body : JSON . stringify ( data )
});
}