Retrieving Wix events data with velo

I am trying to retrieve Wix event data so I can create my own events “repeater” but I cannot figure out how.

I have installed the Wix Events app and have set up some events.

On the page that I want to display a list of events I am using the code below that I found on the Wix velo guide, but it does not work. For starters it doesn’t recognise the 1st line. It says:

"‘wixEvents’ is declared but its value is never read.

Cannot find module ‘wix-events-backend’ or its corresponding type declarations"

----CODE-----------------
import { wixEvents } from “wix-events-backend”;

export function myQueryEventFunction() {
return wixEvents.queryEvents()
.hasSome(“status”, [“SCHEDULED”])
.descending(“createdDate”)
.find()
.then((results) => {
const items = results.items;
const firstItem = items[0];
return firstItem;
console.log(“I found an event item”);
})
.catch((error) => {
console.error(error);
});
}

If anyone has the code to open and loop through events data that would be appreciated!

Many thanks!

Hi there!

I took a look at the code you provided and noticed the quotations you used might have been formatted incorrectly.

After changing it to the proper quotation character, I tested your code and it correctly returned the first event from the Wix Events App.

Here’s the code:

import { wixEvents } from "wix-events-backend"

export function myQueryEventFunction() {
    return wixEvents.queryEvents()
        .hasSome("status", ["SCHEDULED"])
        .descending("createdDate")
        .find()
        .then((results) => {
            const items = results.items;
            const firstItem = items[0];
            return firstItem;
            console.log("I found an event item");
        })
        .catch((error) => {
            console.error(error);
        });
}

You can access the array of events using the items variable.

Thank you!
I tried your code and it works now