Updates a resource.
The updateResource()
function returns a Promise that resolves when a resource is updated.
Use this function to update all bookings resource information except for the resource's schedule. To update a resource's schedule use updateResourceSchedule()
.
Notes:
"business"
and "staff"
.options.suppressAuth
parameter to true
.Note: When updating a resource you cannot change the system tags used by the Wix Bookings app. Tags used by the app have the values "business"
and "staff"
.
function updateResource(
id: string,
resourceInfo: UpdateResourceInfo,
options: Options,
): Promise<Resource>;
ID of the resource to be updated.
Resource information to update.
An object representing the available options for updating a resource.
import { Permissions, webMethod } from "wix-web-module";
import { resources } from "wix-bookings-backend";
export const myUpdateResource = webMethod(
Permissions.Anyone,
async (resourceId) => {
const newPhone = "7778521";
const newEmail = "tomjones@yoga.com";
const options = { suppressAuth: true };
try {
const updatedResource = await resources.updateResource(
resourceId,
{ phone: newPhone, email: newEmail },
options,
);
return updatedResource;
} catch (error) {
console.error("Failed to update resource: ", error);
return error;
}
},
);
/* Updated resource:
*
* {
* "_id": "dc19d7db-6996-494b-8d6d-943d64e1f32a",
* "name": "Tom Jones",
* "email": "tomjones@yoga.com",
* "phone": "7778521",
* "description": "Yoga and self-defense instructor.",
* "tags": [
* "staff"
* ],
* "scheduleIds": [
* "8fbeefbb-76dc-4f67-b292-66e871d5984a"
* ],
* "status": "UPDATED"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.