Question:
I’m making a Widget that calls a backend API function to get data. In Wix Blocks Run environment, This worked perfectly and I got the data I needed, and the widget made updates correctly based on that data. Now I’m finished with the functionality and trying to publish it to my site to test the functionality on a live site. I’ve got the web pages containing the widgets linked and loading data correctly, But my WebModule API call is no longer working - It immediately returns a 400 Error every time. Why is the Backend Web Module (webMethod with permissions.anyone) not be working on the live site? Wix-Data calls that are used to fill other data works fine.
Product:
Wix Blocks Created Widget Backend Web Module Function, used on Wix Studio Website live published site. (can you tell it’s past midnight?)
What are you trying to achieve:
Call the backend Web Module API to get data the widget needs to update correctly.
What have you already tried:
- Tried returning a static return value first line of the method that the webModule calls,
- Tried returning a static value from the WebModule itself (not calling a separate method)
- Tried removing parameters to eliminate if Parameter types may be an issue.
None of these worked. For some reason the live site api call to my method returns 400 error every time.
As mentioned it worked fine in the Wix Blocks Run environment, so it’s not an issue with the method itself.
Additional information:
/backend/my_method.web.js
import { my_method } from “backend/my_method.js”;
export const get_my_method = webMethod(
Permissions.Anyone,
(data, object_id) => my_method(data, object_id)
);
In Widget
import { get_my_method } from “backend/my_method.web.js”;
setParameter(new_param) method :
const data_array = await get_my_method($widget.props.data,$widget.props.objectId);
Console.log(data_array) on live site :
FETCHED DATA ARRAY
- {status: 400, body: {…}, headers: {…}}
- body:
1. error: {} - headers:
1. Content-Type: “application/json” - status: 400
Console.log(data_array) on Wix Blocks Run :
FETCHED DATA ARRAY
[null,null,null,{object_1: value_1},{object_2: value_2},{object_3: value_3},null,null]