TypeError: Cannot read property 'items' of undefined

I am trying to display a reference field from my database as a result on my filtered repeater. I am unsure of how to code the page for this to happen. When testing my code, this is what shows in the developer console:

Loading the code for the SEARCH WITH VIN page. To debug this code, open i5zkm.js in Developer Tools.
Url: https://vpic.nhtsa.dot.gov/api/vehicles/decodevin/19UUA96299A543965/?format=jsonVINModule.jsw
Line 5{...}
SEARCH WITH VIN
Line 14{...}
VINModule.jsw
Line 12
Dataset is now filtered
SEARCH WITH VIN
Line 22
TypeError: Cannot read property 'items' of undefined 

This is my page code:

import {getVINInfo} from 'backend/VINModule';
import {wixData} from 'wix-data';

$w.onReady(function () {
 //TO DO: Write Your Page Related Code Here:
    }); 

export function button1_click(event, $w) {
 //Add your code for this event here:
    getVINInfo($w("#vininput").value)
        .then(VINInfo => {
            console.log(VINInfo)
                      $w("#results").text = VINInfo.Results[8].Value + "  " + VINInfo.Results[5].Value + "  " + VINInfo.Results[7].Value;
                      $w("#dataset1").setFilter(wixData.filter()
                      .eq("year", VINInfo.Results[8].Value)
                      .eq("make", VINInfo.Results[5].Value)
                      .eq("year", VINInfo.Results[7].Value))
 
                      .then((results) =>{
                          console.log("Dataset is now filtered");
                          $w("#repeater1").data = results.items;
 let items = "title"
 
                      }) 
                          .catch((err) => {
                          console.log(err);
        });
        $w("#repeater1").expand();
        })
}

Any and all assistance would be greatly appreciated. I look forward to learning so that I may assist others in need in the near future!

Hi Brittani,

It can be a little confusing, but unlike WixDataQuery and WixDataAggregate, WixDateFilter (or the setFilter command) does not return a result object. From the documentation: “Fulfilled - When the filter has been set. Rejected - An error object.”

I saw some of your other recent posts and I wanted to comment but was too busy to respond in a way that would have been helpful. For your first coding project, you have chosen something that is definitely not a beginner’s task and may not even be an intermediate level programming challenge.

Good evening,
@tony-brunsman Thank you for your response! I’ve been playing with the code all day and think I may have found a solution but am now receiving this error code:

Wix code SDK error: The data parameter that is passed to the data method cannot be set to the value . It must be of type array. 

Here is my current code:

import {getVINInfo} from 'backend/VINModule';
import {wixData} from 'wix-data';


$w.onReady(function () {
 //TO DO: Write Your Page Related Code Here:
        }); 

export function button1_click(event, $w) {
 //Add your code for this event here:
    getVINInfo($w("#vininput").value)
        .then(VINInfo => {
            console.log(VINInfo)
                      $w("#results").text = VINInfo.Results[8].Value + "  " + VINInfo.Results[5].Value + "  " + VINInfo.Results[7].Value;
     $w("#dataset1").setFilter(wixData.filter()
                      .contains("year", VINInfo.Results[8].Value)
                      .contains("make" , VINInfo.Results[5].Value)
                      .contains("model", VINInfo.Results[7].Value))
                          .then((results) =>{
                          console.log("Dataset is now filtered");
 let results2 = "battery"
                          $w("#repeater1").data = results2.data;
                          }) 
                        .catch((err) => {
                          console.log(err);
        });

});
}                   

Any thoughts on where I went wrong with the code?
BTW, battery is the name of the referenced product field from my database.

@tsuyoidesigns As far as Javascript is concerned, the variable results2 is the string “battery”; it doesn’t know that it is the referenced product field from your batteryfitments collection. On the very next line where you are assigning the data to the repeater, it is expecting results2 to be an array because of the dot notation inherent in results2.data.