Hello !
I’m having trouble with
BACKEND http-functions.js
Working in
Velo Backend + wix-events.v2
What I’m trying to do
I try for a given eventId to return its categories in Json format
What I’ve tried so far :
import { ok, notFound, serverError } from "wix-http-functions";
import { categories } from "wix-events.v2";
export async function get_eventCategories(request) {
try {
const url = new URL(request.url);
const eventId = url.searchParams.get("eventId");
if (!eventId) {
return notFound({ error: "Missing eventId parameter" });
}
const results = await categories.listEventCategories(eventId);
const eventCategories = results.items || [];
return ok({
eventId,
categories: eventCategories,
message:
eventCategories.length === 0
? "This event has no category"
: "Success",
});
} catch (error) {
return serverError({ error: error.message });
}
}
Extra context
With POSTMAN :
mydomain/_functions/eventCategories?eventId=a_valid_event_id_having_a_category
returns a status 200 but a completely blank body
Why?