I have created a simple booking website using wix-booking which allows clients to make their appointments through the page, they can choose the day and time of the service depending on availability. I have created an app for that website and trying to obtain the availability of a specific service in json format and I cannot find a way to do it. I already exposed the site to accept http-request and through export function get_services (request) I can get the list of services but I can’t get the availability of a specific service (the hours and days available in json format)
import wixBookings from 'wix-bookings';
import {ok, notFound, serverError} from 'wix-http-functions';
import wixData from 'wix-data';
export function get_services(request) {
let options = {
"headers": {
"Content-Type": "application/json"
}
};
// query a collection to find matching items
return wixData.query("Bookings/Services")
.find()
.then( (results) => {
// matching items were found
if(results.items.length > 0) {
options.body = {
"items": results.items
};
return ok(options);
}
// no matching items found
options.body = {
"error": `'${request.path[0]} ${request.path[1]}' was not found`
};
return notFound(options);
} )
// something went wrong
.catch( (error) => {
options.body = {
"error": error
};
return serverError(options);
} );
}