Question:
Hi everyone, I think I just need help on the correct syntax to parse out JSON response into textbox fields on my webpage as part of an administrative review page.
Product:
Wix Studio Editor
What are you trying to achieve:
Read data from the database (app1) using the uniId (unique ID field/customer number) and take the JSON response and pull values individually into textboxes like legalFirstName and display that value for legalFirstName into a textbox.
I think all i need is help with parsing the response, I am successful in pulling data from the database (please see screenshots)
Full Code
import wixData from ‘wix-data’;
//Variables
let uniIDValue = “”;//On Page Load
$w.onReady(function () {//Filter selection in dropdown for finding new applicants $w('#filterDropdown').onChange(() => { const selectedValue = $w('#filterDropdown').value; let filter = wixData.filter(); if (selectedValue.length > 0) { filter = filter.hasSome("member", selectedValue) } $w('#dataset1').setFilter(filter); });
});
//Red X to reset filter
export function vectorImage1_click(event) {
$w(‘#dataset1’).setFilter(wixData.filter());
}//Review Application Button
export function reviewApplicant_click(event) {//Collect the UniIDValue from the input let uniIDValue = $w('#uniIdInput').value; //Log when its clicked console.log("You Clicked Me!") //Query CMS app1 database using uniId (that the end-user entered) wixData.query("app1") .eq("uniId", uniIDValue) .find() .then((results) => { //Log items into the console console.log(results.items); //I Need help here, how do I parse the JSON response into a textbox //I am getting the full CMS data back, but I want to pull a single value into a single textbox $w('#firstNameTextBox1').value = results.query.eq("legalFirstName").toString(); //this returned an object but not the value });
}
What have you already tried:
See my code example.
Additional information:
this is pretty much a wix velo code syntax question that I do not see covered in the API reference.
