I need to generate QR codes for my dynamic pages. How can I obtain the URL of each dynamic page using VELO code? I have a collection and a field containing the content of the dynamic page called “Properties”. How can I retrieve the complete URL or the final URL of the page in a query?
My code is;
const collectionId = “Inmuebles”;
**const** results = **await** wixData.query(collectionId)
.eq("referencia", referencia)
.find();
return results.items[0].Properties
ERROR: Not URL.

There are multiple ways to fetch the page URL of your dynamic page, depending on your needs.
OR
- You can use the wix-data API to fetch items in your CMS collection and form the URL using the page slug.
It depends on what you are trying to achieve, so the more details you’ll provide, the better we can help you out with a solution.
I only need to get the full URL of the dynamic page, but I can’t get the object using wix-data. It gives me a “undefined object” error when I try to access the field where the URL is located.
This info isn’t enough. First, start by simply using the console to log the results that are returned when you query the collection, and show us your logs, and paste the relevant code here, ensuring that it is neatly formatted using the code block </> so that it makes it readable enough to spot potential issues.
Hello. This is my code:
import wixData from "wix-data";
import { ok, badRequest } from 'wix-http-functions';
/**
* Gets an item by its exact reference value
* @param {string} referencia - The exact reference value to find
* @returns {Promise<Object>} - The matching item or null if not found
*/
export async function getItemByReference(referencia) {
try {
const collectionId = "Properties";
const results = await wixData.query(collectionId)
.eq("referencia", referencia)
.find();
return results.items.length > 0 ? results.items[0] : null;
} catch (error) {
console.error("Error getting item by reference:", error);
throw error;
}
}
/**
* Gets the dynamic page URL for an item by its reference
* @param {string} referencia - The reference value of the item
* @returns {Promise<{url: string, item: Object}>} - The dynamic page URL and the item data
*/
export async function getItemURL(referencia) {
try {
const item = await getItemByReference(referencia);
if (!item) {
throw new Error(`Item with reference ${referencia} not found`);
}
// Construct the dynamic page URL using the item's reference
// The actual URL structure depends on how the dynamic pages are set up
// Typically, it would be something like "/items/[reference]"
const urlvivienda = item.Properties;
return {
url : urlvivienda,
item : referencia
};
} catch (error) {
console.error('Error al obtener los datos:', error);
throw error;
}
}
export const invoke = async ({ payload }) => {
const urlvivienda = await getItemURL("MP1051");
let datos={'url' : urlvivienda.url,
'x_studio_referencia' : urlvivienda.item}
//await enviarDatos(datos);
console.error("Error al enviar datos:", datos.url);
return {};
};
I need to obtain the content of the field shown in the image.