wixLocation.query empty upon form submission

Hi There,

I have a site that passes URL parameter into an input field before submission.
However, I intermittently receiving the notification email (image below) with an empty value from input1 - even though I could see the param being populated from my page before submission.

Seeking your help / advice on how to solve this issue. A workaround perhaps?

Thanks.

URL:
https : //www. example. com/ page? cn=01234

Email Notification:

CODE:
import wixLocation from ‘wix-location’ ;

$w . onReady ( async function () {

$w ( “#input1” ). hide ();

const user = wixUsers . currentUser ;
const userId = user . id ;
const loggedIn = user . loggedIn ;

let cntrlno = await wixLocation . query . cn ;

if ( loggedIn ) {
wixData . query ( “Members/PrivateMembersData” )
. eq ( “_id” , userId )
. find ()
. then (( results ) => {

           $w ( "#input1" ). value  =  cntrlno  +  "-"  +  results . items [ 0 ]. firstName  +  " "  +  results . items [ 0 ]. lastName 
        }) 

}

});

  1. It’s better use curretnMember.getmember() or at least wixData.get(‘Collection’, id) no need to use wixData.query.

  2. Try to add console.log() 's to locate the problem.