My code works for ’ Preview Mode ’ but not on the published site.
All I am trying to do is to customize my date so I ran it through the backend code to give the correct date that I wanted set up. It works well on my preview site but for some reason, it isn’t working on my published site. Please advise. I really don’t know why the code doesn’t work on the Published Site. It might be a simple fix on my end but I really did all the steps that I could think of to make it work.
My backend permissions are open to anyone to run the code.
My Database permission is set to Site Content
My site permissions are open to anyone to view the site
But I still run into this error:
Error: Not Found
at s (wixCodeNamespacesAndElementorySupport.min.js:3)
at XMLHttpRequest.n.onreadystatechange
(wixCodeNamespacesAndElementorySupport.min.js:4)
at XMLHttpRequest.wrapped (raven.js:375)
Front End Code
import { convertShortDate } from 'backend/date-time/loaddate.jsw'
$w.onReady(function () {
convertShortDate(item.open_date).then((res) => {
convertShortDate(item.closing_date).then((res1) => {
console.log(res)
console.log(res1)
if (res !== undefined) {
if (res1 !== undefined) {
$w("#text155").text = res + " - " + res1
} else {
$w("#text155").text = res + " - Open Until Filled"
}
} else {
$w("#text155").text = "No date posted"
}
})
.catch((err) => {
console.log("error1")
console.log(err)
})
})
.catch((err) => {
console.log("error")
console.log(err)
})
})
Backend Code
export function convertShortDate(DateIn) {
if (DateIn === null) {
return undefined
} else {
let thisDay = DateIn.getDate();
let strthisDay = "0" + thisDay.toString();
strthisDay = strthisDay.substr(strthisDay.length - 2, 2);
//console.log(strthisDay)
let thisMonth = DateIn.getMonth() + 101;
//console.log(thisMonth)
let strthisMonth = thisMonth.toString();
//console.log(strthisMonth)
strthisMonth = strthisMonth.substr(strthisMonth.length - 2, 2);
//console.log(strthisMonth)
let thisYear = DateIn.getFullYear().toString();
//console.log(thisYear)
let formattedDate = strthisMonth + "/" + strthisDay + "/" + thisYear;
//console.log(formattedDate)
return formattedDate;
}
}
#pleasehelp #wixcode #database #codeerror #backenderror
#corvidislife #corviderror #pleaseadvise #keephopealive