I am trying to pull results from my database to use in another query but have not had any luck. I’ve read several articles and checked the wixDataQuery documentation but can’t seem to find out why my query has no results. Here is my 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)
let year = VINInfo.Results[9].Value;
let make = VINInfo.Results[6].Value;
let model= VINInfo.Results[8].Value;
let engine= VINInfo.Results[71].Value + " "+ "L"
$w("#results").text = "Vehicle Specific Battery for Your" + " " + VINInfo.Results[9].Value + " " + VINInfo.Results[6].Value + " " + VINInfo.Results[8].Value;
wixData.query("battery2221")
.eq("year", year)
.and(wixData.query("battery2221")
.eq("make", make)
.and(wixData.query("battery2221")
.eq("model", model)
.and(wixData.query("battery2221")
.contains("engine", engine))))
.find()
.then((results1) => {
let results = results1;
if(results.items.length > 0) {
let items = results.items; // see below
console.log(results1);
} else {
console.log("NOT FOUND");
}
The result I get from each search always returns the following:
Url: https://vpic.nhtsa.dot.gov/api/vehicles/DecodeVinExtended/KNDJP3A55H7474332/?format=json
VINModule.jsw
Line 6
{...}
SEARCH WITH VIN
Line 13
{...}
VINModule.jsw
Line 13
{...}
jsonTableCopy JSON
_items:
[...]
_totalCount:
0
_query:
{...}
jsonTableCopy JSON
orderBy:
"undefined"
invalidArguments:
Array(0)
jsonTableCopy JSON
filterTree:
{...}
jsonTableCopy JSON
$and:
Array(2)
jsonTableCopy JSON
0:
{...}
jsonTableCopy JSON
$and:
Array(1)
jsonTableCopy JSON
0:
"[Object]"
1:
{...}
jsonTableCopy JSON
$and:
Array(2)
jsonTableCopy JSON
0:
"[Object]"
1:
"[Object]"
provider:
{...}
collectionName:
"battery2221"
limitNumber:
50
skipNumber:
0
included:
Array(0)
jsonTableCopy JSON
_partialIncludes:
"undefined"
_pagingFunction:
"function e(){return this.find(t)}"
nextSkipNumber:
0
prevSkipNumber:
-50