Backend Module Function Returns Undefined in Wix Velo - ping() is not a function

Hello,
I am developing a booking system using Wix Velo.
In the backend, I created a file named booking.web.js in the Backend folder and defined a simple test function, ping(), as follows:

export function ping(){
  return "pong";
}

Then, in my frontend code (ReservationForm Lightbox), I imported and called the function like this:

However, in the console, I receive the error:
TypeError: (0 , booking_web.ping) is not a function
and ping() appears as undefined.

I have verified that the file is correctly placed in the Backend folder, the file name (“booking.web.js”) is correct, and the export method (named export) is properly set up (since if the file name or path were wrong, I would see red underlines in the editor). Despite all this, the function remains undefined when imported.

Has anyone encountered a similar issue or have any insights on why the backend module function might not be imported correctly in Wix Velo? Any help would be greatly appreciated.

Thank you!

Hi, @user5418 !!

To call backend code from the frontend, you need to use imports from files defined with either .jsw or .web.js. In your case, the issue arises because your function is defined using the .jsw approach, but it is being called as if it were a .web.js function. Standardizing the function definition to the .web.js approach should likely resolve the problem. I’ve included a reference link—try making the necessary adjustments. :raised_hands: :smiling_face_with_halo:

like this

import { Permissions, webMethod } from "wix-web-module";

export const ping = webMethod(Permissions.Anyone, () => {
  return "pong";
});

// another functions ...