Not sure why scheduled job returning error of "is of unexpected format" when testing export function works fine.

Wix scheduled job returning error of " is of unexpected format" but I’m not sure what the unexpected format it is referring to.

I’m trying to schedule a daily backend script function that queries a database, pulls unique values from a field column, then updates a different database field with an array of unique values based on “_id”. Testing the export function manually works and updates the database (even though the console output states “returned with undefined”). When I schedule the job with jobs.config though it fails…

Script : LoadCurrCats.jsw

import wixData from “wix-data” ;

let styles_all = ;
let stylesDropdownOptions = ;

function JSONtoArray_Unique ( obj ) {
let mySet = new Set ();
obj . forEach ( object => {
for ( var key in object ) {
var valjson = object [ key ];
mySet . add ( valjson )
}
});
// turn set into array and order alphabetically
let array = Array . from ( mySet ). sort ();
console . log ( array );
return array
}

function styles () {
// generic function to get array of unique values from JSON
return wixData . query ( ‘Inventory’ ). find (). then ( results => {
// Create and map an array for the dropdown menu options
let styles = results . items . map ( e => e . style );
styles_all = JSONtoArray_Unique ( styles );
let idx = 0 ;
for (; idx < styles_all . length ; idx ++) {
// console.log(styles_all[idx]);
stylesDropdownOptions . push ({ “_id” : String ( idx ), “value” : styles_all [ idx ], “label” : styles_all [ idx ] });
}
console . log ( stylesDropdownOptions );
let toUpdate = {
“_id” : “8e97f2aa-c393-41fc-a642-4454364542c4” ,
“categories” : “Styles” ,
“options” : stylesDropdownOptions
};
return toUpdate
})
}

export function GetStyles () {
return styles (). then (( toUpdate ) => {
console . log ( toUpdate );
wixData . update ( “Categories” , toUpdate )
})
}

Jobs.config :
{
“jobs” : [
{
// GetStyles
“functionLocation” : “Backend/Data/LoadCurrCats.jsw” , // Relatively to Backend folder, started by slash
“functionName” : “GetStyles” ,
“description” : “This updates the Categories database based on what ‘Styles’ are currently in the collection” , // Optional
“executionConfig” : {
“cronExpression” : “34 * * * *” // Set intervals of up to 1 hour
}}
]
}

Any help or guidance would be much appreciated.