Hi Guys,
I’m hitting a wall and tried to search for answers. This is my current http-functions.js (auto-generated when I created the file)
import {ok, badRequest} from 'wix-http-functions';
export function get_example(request) {
const response = {
"headers": {
"Content-Type": "application/json"
}
};
// Get operation from the request path
const operation = request.path[0]; // "multiply"
const leftOperand = parseInt(request.query["leftOperand"], 10); // 3
const rightOperand = parseInt(request.query["rightOperand"], 10); // 4
// Perform the requested operation and return an OK response
// with the answer in the response body
switch (operation) {
case 'add':
response.body = {
"sum": leftOperand + rightOperand
};
return ok(response);
case 'multiply':
response.body = {
"product": leftOperand * rightOperand
};
return ok(response);
default:
// If the requested operation was not found, return a Bad Request
// response with an error message in the response body
response.body = {
"error": "unknown operation"
};
return badRequest(response);
}
}
The above code works and returns the proper result.
When I try to edit this and just add even an “import wixBookings from ‘wix-bookings’;” I will get a 404 .
Or if I replace the whole file with this one I will get also a 404:
import {ok, badRequest} from 'wix-http-functions';
import wixData from 'wix-data';
import wixBookings from 'wix-bookings';
export function get_myBookings(request){
let options = {
"headers": {
"Content-Type": "application/json"
}
};
let serviceId = "validServiceId";
return wixBookings.getServiceAvailability(serviceId)
.then( (availability) => {
let slots = availability.slots;
let firstSlot = slots[0];
} );
}
Thank you so much in advance for your positive reply.