Error (Wix code SDK Warning: The text parameter of "text34" that is passed to the text method cannot be set to null or undefined.)

Hi I am new with wix corvid. I am trying to get something simple done, but keep getting an error.

Error ( Wix code SDK Warning: The text parameter of “text34” that is passed to the text method cannot be set to null or undefined. )

Here is what I am trying to do:

I have a collection (“Passport_Index”)

With four columns. (title, passport, destination, code)

A page with user input textbox (input1, input2).
“input1” textbox is connected to collection “Passport_index” column “passport”
“input2” textbox is connected to collection “Passport_index” column “destination”

A button to execute a query using the user input from “input1” and “input2”

(query: I want the “code” in collection “Passport_Index” where “passport” equals user input “input1” and “destination” equals user input “input2”)

A regular textbox (“text34”) to display the result (“code”) of the query.

Here is my current code:

// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import wixData from ‘wix-data’ ;

$w.onReady( function () {
// TODO: write your page related code here…
});
export function button2_click(event) {
// Add your code for this event here:
//let newQuery = query1.and(query2);
wixData.query( “Passport_Index” )
.contains( “passport” , $w( #input1 ).value).and(wixData.query( “Passport_Index” )
.contains( “destination” , $w( #input2 ).value))

.find()
.then( (results) => {
console.log(results);
let item = results.items;
let code = $w( #text34 )
results = toString(results)
$w( #text34 ).text = results.items;
} );
}

I’m not sure you are query the database in the right way, but lets say you are.
the results you get from the database is “Promise” object

result.items is an array represents all of the items that returned from the query.
so if you need to get only one item from this query result.items will look like this:

array = [
    {
        "title" : something,
        "passport" : something,
        "destination" : something,
        "code" : something,
    }
];

If you want to display that “code” in the text field you need to :

import wixData from 'wix-data';
 
$w.onReady(function () {
 // TODO: write your page related code here...
});
export function button2_click(event) {
 // Add your code for this event here: 
 //let newQuery = query1.and(query2);
    wixData.query("Passport_Index")
    .contains("passport", $w("#input1").value).and(wixData.query("Passport_Index")
    .contains("destination", $w("#input2").value))
 
    .find()
    .then( (results) => {
          console.log(results);
          $w("#text34").text = results.items[0].code;
      } );
}

Good luck!

thank orhirschhorn14 , let me try that