Hi, I am trying to load data based on the querystring. Below is the code I have but its not working.
// API Reference: https://www.wix.com/velo/reference/api-overview/introduction // “Hello, World!” Example: https://learn-code.wix.com/en/article/1-hello-world import wixLocation from 'wix-location'; import wixData from 'wix-data'; $w.onReady(function () { let queryUser = wixLocation.query['user']; wixData.query("Wedding_Inquiry") --this is the name of the database hooked with the form .eq('Email',queryUser) .find() .then((results)=>{ console.log(JSON.stringify(results)); --i cannot see any results in the console window //let item = results.items[0]; //console.log(item); //$w('#userName').value = item.Email; --when i enable this line, i cannot see anything populated }) .catch((err)=>{console.log(err)}); });
Need helps pls :)
Thanks,
Zeba
You should use more console-logs to inspect your own code a little bit more.
Do you get your wished result for ---> console.log(queryUser)
Do you get your wished result for ---> console.log(results)
import wixLocation from 'wix-location'; import wixData from 'wix-data'; $w.onReady(function () { let queryUser = wixLocation.query['user']; console.log(queryUser) wixData.query("Wedding_Inquiry") .eq('Email',queryUser) .find() .then((results)=>{console.log(results) console.log(JSON.stringify(results)); }) .catch((err)=>{console.log(err)}); });
Find out which of the two results do not work.
Could it be ---> 'Email', which is wrong?
Check again the 'Email'-ID of your -datafield in your DB.
Check also the right ID of your wished DB ---> "Wedding_Inquiry"