I’m trying to get some kind of content search working with HubDB tables, and even though I know the content is there, I’m always getting back an empty results set.
The URL is more or less:
https://api.hubapi.com/contentsearch/v2/search?portalId=<nnn>&term=sales&tableId=<nnn>
If I drop the
tableId
, I get back records for other content, but I need to be able to peek inside the HubDB tables specifically.
Any ideas?
Hi, @morungos1 Thanks your question — @piersg do you have any thoughts here?
Thank you! — Jaycee
piersg
July 18, 2022, 9:10am
3
Hi @morungos1 , the content search API wouldn’t work for this. I just use fetch/AJAX and the HubDB API to do this, e.g.
const searchResult = (url, searchItem) => {
fetch(url)
.then(response => response.json()
.then(data => {
const results = data.objects;
results.forEach(obj => { // gives you each row of the table
// search for something e.g.
if (obj.name.toLowerCase().includes(searchItem.toLowerCase())) {
console.log(obj);
}
});
})
)
};
const url = "https://api.hubapi.com/hubdb/api/v2/tables/[TABLE ID]/rows?portalId=[PORTAL ID]";
searchResult(url, "sales");