Automation, working with external custom API

Hello,

Read a lot of articles.
I see 2 variants from my understanding, it could be either events from “event.js” in backend, like this (don’t work for me):

import wixData from ‘wix-data’ ;
import wixStores from ‘wix-stores-backend’ ;

export function button8_click(event) {
console.log( “Button clicked!” )
}

export function wixStores_onCartCreated(event) {
let total = event.totals.total;
wixData.insert( ‘Logs’ , { ‘title’ : total})
console.log( “New Cart!” )
}

export function wixStores_onNewOrder(event) {
let newOrderId = event.orderId;
wixData.insert( ‘Logs’ , { ‘orders’ : newOrderId})
console.log( “New Order!” )

}

import wixStoresBackend from ‘wix-stores-backend’ ;

export function wixStoresBackend_onCartCreated(event) {
wixData.insert( “logs” , { “log” : “test from events” });
console.log( “New Order bB.E>!” )
}

Or using Hooks (will try to test soon).