WDE0025: Error any help

WDE0025: Error

WDE0025: The Stores/products collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor.

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

$w.onReady(function () {
LoadRelatedProducts();
});

async function LoadRelatedProducts() {
let product = await $w(‘#productPage’).getProduct();
let relatedProductsResult = await Promise.all ([
relatedProductsByTable(product),
relatedProductsByPrice(product)
]);

if (relatedProductsResult[0].length > 0) 
    showRelatedProducts(relatedProductsResult[0]); 
else 
    showRelatedProducts(relatedProductsResult[1]); 

}

async function relatedProductsByPrice(product) {
let productId = product._Id;

let relatedByPrice = await wixData.query(`Stores/products`) 
.between('price', product.price * 0.8, product.price * 1.2) 
.ne('_id', productId) 
.find(); 

return relatedByPrice.items; 

}

async function relatedProductsByTable(product) {
let productId = product._id;

let relatedByTab = await Promise.all([ 
	wixData.query('relatedProducts') 
	    .eq('productA', productId) 
		.include('productB') 
		.find(), 
    wixData.query('relatedProducts') 
	    .eq('productB', productId) 
		.include('productA') 
		.find()				 
]); 

let relatedProducts = [
…relatedProductsByTable[0].items.map(_ => .productB),
…relatedProductsByTable[1].items.map(
=> _.productA)
];
return relatedProducts;
}

function showRelatedProducts(relatedProducts) {
if (relatedProducts.length > 0) {
relatedProducts.splice(4, relatedProducts.length);
$w(‘#relatedItemsRepeater’).data = relatedProducts;
$w(‘#relatedItemsRepeater’).onItemReady(relatedItemReady);
$w(‘#relatedItems’).expand();
}
else {
$w(‘#relatedItems’).collapse();
}
}

function relatedItemrReady($w, product) {
$w(‘#productimage’).src = product.mainMedia;
$w(‘#productName’).text = product.name;
$w(‘#productPrice’).text = product.formattedPrice;
$w(‘#productImage’).onClick(() =>{
wixLocation.to(product.productPageUrl);
})
}

Anybody will work on this project to help you! WHY ???
-anybody want to waste time just to retype all your code from a pic!

So if you expect an answer, please be so kind and provide your code in a nicely formated → CODE-BLOCK!

Thanks for you info,

Ok, your first try to show CODE in a CODE block was ok but not 100% :grin:

This was expected from you…

import wixData from 'wix-data';
import wixLocation from 'wix-location';
// For full API documentation, including code examples, vist http://wix.to/94BuAAs


$w.onReady(function () {
LoadRelatedProducts();
});

async function LoadRelatedProducts() {
	let product = await $w('#productPage').getProduct();
	let relatedProductsResult = await Promise.all ([
		relatedProductsByTable(product),
		relatedProductsByPrice(product)
	]); 


	if (relatedProductsResult[0].length > 0)
	    showRelatedProducts(relatedProductsResult[0]);
	else
	    showRelatedProducts(relatedProductsResult[1]);
}


async function relatedProductsByPrice(product) {
    let productId = product._Id;


    let relatedByPrice = await wixData.query(`Stores/products`)
    .between('price', product.price * 0.8, product.price * 1.2)
	.ne('_id', productId)
	.find();
 
	return relatedByPrice.items;
}


async function relatedProductsByTable(product) {
	let productId = product._id;


	let relatedByTab = await Promise.all([
		wixData.query('relatedProducts')
		    .eq('productA', productId)
			.include('productB')
			.find(),
	    wixData.query('relatedProducts')
		    .eq('productB', productId)
			.include('productA')
			.find()				
	]);

   let relatedProducts = [
	   ...relatedProductsByTable[0].items.map(_ => _.productB),
	   ...relatedProductsByTable[1].items.map(_ => _.productA)
   ];
   return relatedProducts;
}

function showRelatedProducts(relatedProducts) {
	if (relatedProducts.length > 0) {
		relatedProducts.splice(4, relatedProducts.length);
		$w('#relatedItemsRepeater').data = relatedProducts;
		$w('#relatedItemsRepeater').onItemReady(relatedItemReady);
		$w('#relatedItems').expand();
	}
    else {
	    $w('#relatedItems').collapse();
	}
}

function relatedItemrReady($w, product) {
    $w('#productimage').src = product.mainMedia;
	$w('#productName').text = product.name;
	$w('#productPrice').text = product.formattedPrice;
	$w('#productImage').onClick(() =>{
        wixLocation.to(product.productPageUrl);
	})
}

A nicely formated CODE in a CODE-BLOCK.

Ok back to your issue!

WDE0025: The Stores/products collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor.

What does this error want to tell us?
-Maybe the referenced DATABASE do not exist?
-Maybe you wrote the DB-ID incorectly? (attention on upper and lower-case).