Hubdb column data not showing using api call

Hi, not a developer per se in here :grimacing: The code im using was generated in chatgpt.

I am trying to retrieve data colum values from a hubdb table and public api calls. This is my code, i am not using authentication because i have the public api option in the table.

<h1>Contenido de la Tabla de HubDB</h1>
<table id=“tableData” style=“border-width: 1px; border-style: solid;”>
<tbody>
<tr>
<th style=“border-width: 1px; border-style: solid;”>ID</th>
<th style=“border-width: 1px; border-style: solid;”>Nombre del Producto</th>
<th style=“border-width: 1px; border-style: solid;”>Precio del Producto</th>
</tr>
</tbody>
</table>
<script>
// Portal ID y ID de la tabla en HubDB
var portalId = ####;
var tableId = #####;

// URL de la API de HubDB para obtener los datos de la tabla
var url = `https://api.hubspot.com/cms/v3/hubdb/tables/${tableId}/rows?portalId=${portalId}\`;

// Realizar una solicitud GET a la API de HubDB utilizando AJAX
var xhr = new XMLHttpRequest();
xhr.open(“GET”, url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
var table = document.getElementById(“tableData”);

// Iterar sobre los resultados y agregarlos a la tabla HTML
data.results.forEach(function(row) {
var newRow = table.insertRow(-1);
var idCell = newRow.insertCell(0);
var nameCell = newRow.insertCell(1);
var priceCell = newRow.insertCell(2);
idCell.innerHTML = row.id;
nameCell.innerHTML = row.name; // Acceder a la propiedad ‘NAME’
priceCell.innerHTML = row.precio_producto; // Acceder a la propiedad ‘PRECIO’
});
}
};
xhr.send();
</script>

This is my database, and with the id values you can see that it connects with the database but only shows Ids, and Producto and Precio values are missing.

Why aren´t the row values showing? Sorry about my english, its not my first language. Hope you can help me.

@MBravo0 - I’ve undertaken a few projects using the public HubDB API like this, and all that you are doing looks consistent with my experience (esp. using the internal column name definitions). I would say that I have bumped up against limits on the size of database you can access this way. Dealing with those limits throws you into a world of async JavaScript calls which took me a while to figure out. But this is unlikely your porblem here :slightly_smiling_face:

I have one question - forgive me for asking, but its tripped me up a number of times in development - have you “published” the version of the HubDB database that has the filled data fields you are trying to access?

Steve

Hi Steve, thanks for reply! Yes i already published the table. So, i don´t know what am i doing wrong.