Hi there, I’m trying to build a custom booking calendar with embed code. At some point, I need to retrieve all duration variants / options for a given service id, but the key field I retrieve from the API has the literal value of “[object]”.
Here is my code:
import { serviceOptionsAndVariants } from "wix-bookings.v2";
const res = await getDurations(<serviceId>)
console.log(res)
async function getDurations(serviceId) {
const query = {
filter: {
serviceId: { $eq: serviceId }
}
};
const response = await serviceOptionsAndVariants.queryServiceOptionsAndVariants(query);
return response.serviceOptionsAndVariantsList;
}
Here is the JSON data I got:
{
"serviceVariants": {
"serviceId": "6428a612...",
"options": {
"values": [
{
"type": "DURATION",
"durationData": {},
"_id": "5cabc5e..."
}
]
},
"variants": {
"values": [
{
"choices": [
"[Object]"
],
"price": {
"value": "95",
"currency": "GBP"
},
"_id": "935a32..."
},
{
"choices": [
"[Object]"
],
"price": {
"value": "145",
"currency": "GBP"
},
"_id": "58e739..."
},
{
"choices": [
"[Object]"
],
"price": {
"value": "70",
"currency": "GBP"
},
"_id": "b91d32..."
}
]
},
"minPrice": {
"value": "70",
"currency": "GBP"
},
"maxPrice": {
"value": "145",
"currency": "GBP"
},
"revision": "4",
"_id": "57f3d..."
}
}
According to your documentation, this “choices” field should have info of the choice (e.g. if choice type is STAFF MEMBER, then there is “staffMemberId” in the “choices” field, but it shows “[Object]” in the raw response. It seems a serialization bug.
What I have tried:
I have already tried
-
importing this module from “@wix/bookings”,
-
the other function Get Service Options And Variants By Service Id,
and I always got “[Object]” for “choices”.
Asking for help:
Could you please fix this issue or tell me if there’s any other way to get the choice-price pairs for a given service? Thank you very much.
Kind regards