Hi! I have code to fill a search dropdown on my site which is causing this error sporadically. It does not happen in Preview mode, but it does happen in my live site (sometimes, it does not happen).
I basically call an aggregate on a collection, and then call a get on a referenced collection for each of the retrieved items, wait for them with Promise.all(), and return them. Then I format them as options for my dropdown. The problem seems to happens between the second and third console.log() statements. This code is in my page onReady section.
Here is the code:
import wixData from 'wix-data';
$w.onReady(function () {
let seriesAggregate;
wixData.aggregate("Mensajes")
.group("serie")
.max("fecha")
.descending("fechaMax")
.run()
.then( result => {
console.log("First then() started.");
seriesAggregate = result;
//Obtener informacion de las series
let series = [];
result.items.forEach( item => {
series.push(wixData.get("Series", item._id));
console.log(item);
})
console.log("First then() finished.");
return Promise.all(series);
}).then( series => {
//Agregar información de las series al resultado anterior
console.log("Second then() started.");
let i = 0;
seriesAggregate.items.forEach( item => {
item.titulo = series[i].titulo;
item.orden = series[i].orden;
i++;
});
//Organizar según orden seleccionado en la base de datos
seriesAggregate.items.sort( (a, b) => { return a.orden - b.orden });
//Crear opciones para el dropdown
let options = [{"value": "", "label": "Todos"}];
options.push(...seriesAggregate.items.map( serie => {
let ano = serie.fechaMax.getFullYear();
let mes = serie.fechaMax.toLocaleDateString("es-ES", {month: 'short'});
return {"value": serie._id, "label": mes + " " + ano + "-" +
serie.titulo};
}));
$w('#dropdownSerie').options = options;
console.log("Second then() finished.");
});
});
Here’s the error I get in Site Monitor:
"root":{
"insertId":".........06CI3Ya.6C15d7BgGwLkY2V"
"timestamp":"2020-06-02T07:29:43.508Z"
"severity":"ERROR"
"labels":{
"siteUrl":"https://www.graciasoberana . org"
"namespace":"Corvid"
"tenantId":"d8eae1fc-ddad-4b7c-8645-b7420a6d131c"
"viewMode":"Site"
"revision":"909"
}
"operation":{
"id":".........030mQbSfi48IPymQHmyZENo"
"producer":"/mensajes"
"first":false
"last":false
}
"sourceLocation":{}
"jsonPayload":{
"message":"Error at i (https://static.parastorage . com/services/wix-code-platform/1.425.0/wixCodeNamespacesAndElementorySupport.min.js:1:97416) at XMLHttpRequest.n.onreadystatechange (https://static.parastorage . com/services/wix-code-platform/1.425.0/wixCodeNamespacesAndElementorySupport.min.js:1:97890) at XMLHttpRequest.wrapped (https://www.graciasoberana . org/_partials/wix-bolt/1.5976.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:18:57954)"
}
"receiveTimestamp":"2020-06-02T07:29:44.435Z"
}
And here’s the error I get in my browser’s inspect window:
Uncaught (in promise) Error
at i (wixCodeNamespacesAndElementorySupport.min.js:1)
at XMLHttpRequest.n.onreadystatechange (wixCodeNamespacesAndElementorySupport.min.js:1)
at XMLHttpRequest.wrapped (raven.js:375)
Thank you for any help on how to resolve this!