I need to retrieve all the bookings done by users and hence I am using this code in backend-
import {bookings} from "wix-bookings-backend";
export function queryBookings() { return bookings .queryBookings() .find() .then((queryResult) => { console.log(queryResult) return queryResult.items; }) .catch((error) => { return error; }); }
The code runs fine but returns an empty array. Am I doing something wrong?
Thanks in advance to anyone who can provide a suggestion or explanation.
By default, queryBookings() retrieves only statuses of "CONFIRMED". To retrieve all booking statuses use a hasSome() filter with all of the statuses.
A member can only see their own bookings unless suppressAuth is set to true in the queryOptions for the find() function.
import { bookings } from "wix-bookings-backend"; let options = { suppressAuth: true } export function queryBookings() { return bookings .queryBookings() .hasSome("status", ["PENDING_CHECKOUT", "CONFIRMED", "CANCELED", "PENDING", "PENDING_APPROVAL", "DECLINED"]) .find(options) .then((queryResult) => { return queryResult.items; }) .catch((error) => { return error; }); }
Hope this help...