I am trying to resolve a URL to redirect to in the backend. It is working perfectly and popping up that the link will work on my published site. However, on my published site it is not working and I am getting an “Uncaught (in promise)” in the console.
Here is my code:
Client-side:
let paymentInfo = {
productId: "productId",
itemName: "item_name",
chosenDate: chosenDate,
}
console.log("hi" + paymentInfo)
urlRedirect(paymentInfo).then(newUrl => {
console.log(newUrl)
wixLocation.to(newUrl)
})
Backend:
import wixData from 'wix-data';
export async function urlRedirect(paymentInfo) {
let price = await wixData.get("productNames", paymentInfo.productId)
console.log(price)
let newUrl = "https://www.somelink.com/"+paymentInfo.purpose
newUrl= newUrl.replace(" ", "+")
return newUrl
}
I checked and all the the collection permissions are set up correctly