Question:
I make it very simple what i need to do with Wix I am am a Apple Swift UI Swift developer who wishes to fetch all products that are listed on my site and filter them into a select list on my ios app i was hopeing to use rest api top do this i used a ai to help me Wix because there is limited to no info to help me do what i need
I setup a java script in the back end to do the following to get a list of products out in json to send to my app client end code in section in wix dev screen {} called backend / backend/products.js
import { wixData } from ‘wix-data’;
export async function getAllProducts() {
try {
const products = await wixData.query(“Products”).find();
return products.items;
} catch (error) {
return { error: error.message };
}
} and a sceond file in the same place called // backend/http-functions.js
import { ok, serverError } from ‘wix-http-functions’;
import { getAllProducts } from ‘backend/products’;
export function get_allProducts(request) {
return getAllProducts()
.then(products => {
return ok(products);
})
.catch(error => {
return serverError({ error: error.message });
});
}