emails with wix email activation.

Hi guys!
I am currently developing code in Wix that allows me to send emails with wix email activation.
First I make a query to my database to get all the id’s of the users, then with help
From a for loop, I loop through that array while executing a method that sends the email to the user according to
The ID; I also use the async/await statement in my function to ensure that the method finishes executing,
But the catch throws me a 404 error, I would like to know if you can help me solve this problem, thank you very much.

Please share your code so that we can see what the issue might be.

Hi you are right!

export async function Empleos_afterInsert(item, context) {
item.empleoID = item._id;
await sendNotificationsToUser(item);
return item;
}

export async function sendNotificationsToUser(jobInfo) {
let response = await getUserWithInteres();
for (let i = 1; i < response.length; i++) {
let info = {
“genero”: jobInfo.genero,
“detalles”: jobInfo.detalles,
“empresa”: jobInfo.empresa,
“barrio”: jobInfo.barrio,
“nivelEstudios”: jobInfo.nivelDeEstudio,
“subArea”: jobInfo.subareaDeEmpleo,
“empleoCard”: jobInfo[‘link-empleos-4-title’],
“areaPrincipal”: jobInfo.areaPrincipal,
“nameUser”: jobInfo.nameUser,
“disponibilidadHoraria”: jobInfo.disponibilidadHoraria
}
await sendEmailsToMembers(response[i]._id, info);
}
}

export async function getUserWithInteres() {
let options = {
“suppressAuth”: true
};
let result = await wixData.query(“Empleados”)
.contains(“intereses”, “Home office”)
.and(wixData.query(“Empleados”)
.eq(“notificacionesIntereses”, true))
.limit(500)
.find(options);
let allItems = result.items;
while (result.hasNext()) {
result = await result.next();
allItems = allItems.concat(result.items);
}
return allItems;
}

export async function sendEmailsToMembers(memberId, info) {
const options = {
variables: {
genero: “info.genero”,
detalles: “info.detalles”,
empresa: “info.empresa”,
barrio: “info.barrio”,
nivelEstudios: “info.nivelEstudios”,
subArea: “info.subArea”,
empleoCard: “info.empleoCard”,
areaPrincipal: “info.areaPrincipal”,
nameUser: “info.nameUser”,
disponibilidadHoraria: “info.disponibilidadHoraria”
}
}
return await triggeredEmails.emailMember(‘TSCSfek’, memberId, options)
.then(() => {
console.log(‘Email was sent to member’);
})
.catch((error) => {
console.error(error);