Backend Code <Need Solving>

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

First of all, if you have 2 promises to run and each of them does not depend on the results of the other one, you should run them in parallel:

Promise.all([convertShortDate(item.open_date), convertShortDate(item.closing_date)])
.then(allRes => {
    let res = allRes[0];
    let res1 = allRes[1];
    //etc...
})

Second, I can’t see where you declare/retrieve the “item” (on the front end)
Third, not sure how you want to format your dates (I didn’t read your entire code, but there’re many chances you can partly do it using JS date methods).
Forth, isn’t it a waist of time to send it back and forth from client to server?

@J.D.
First, Thank you for your valuable response.
Second, I will try to run the shortly. I appreciate the suggestion.
Third, It’s cool I wasn’t expecting anyone to read the code but I just put it there for convenience for anyone else.
Fourth, it sounds like a waist of time but I am doing some data collection while producing the dates. So I would rather do the wix-data in the backend. I appreciate your concerns though. I totally would put it back on the client side if this was the case.