Hello all,
For internal use, I want to develop a page which displays the list of all the companies present in our Hubspot account. But looks like my code doesn’t run through While loop.
Also, I am not sure if {{ company_domain}} is correct. I don’t want my company domain. I want Contacts Company domain.
<script>
while({{ company_domain}}){
var item=[];
item=[“{{company_domain}}”,“{{company_state}}”, “{{company_country}}” ];
var e = item.toString();
document.getElementById(“result1”).innerHTML = e;
end
}
</script>
<button type=“button” onclick=“state1();”>Click Me!</button>
<p><span id=“result1”>\ </span></p>
Hey @mansigovani
I apologize for the delay in getting back to you. I am wondering if you were able to resolve this or if you still need assistance on this matter? If so, could you please share the URL?
Thank you
Sharon
Hello @sharonlicari ,
No, I am nowhere near completion on that project. I tried a couple of different methods but I was not able to figure out the solution for it.
Your help will be much appreciated.
Just a brief idea of what I want as a result: A custom web page, where I can filter three of my Hubspot Company properties: Country, State, and Customer Type. Based on those results, I should be able to get all the companies that match the filter criteria (Just like the HubSpot CRM Companies Page) but a web page.
I hope that makes sense and you will be able to help me out here.
Thank you in advance!
Mansi
Hey @mansigovani
Thank you for your fast response. I will tag a few of our experts to give you some tips about this.
Hey @DanielSanchez @alyssamwilie @Kevin-C could you please share your knowledge with @mansigovani
Happy Friday,
Sharon 
Hey @mansigovani ,
Any Hubl property variables are only going to pull the contact properties associated with the current user. To output a list of all companies or particular properties you would need to use the Hubspot API.
Hello @alyssamwilie ,
Thank you for your quick response. Earlier I talked to HubSpot support, and he coordinated with developers on this. Please see the attached screenshot.
Here’s the sample of code from [https://www.youtube.com/watch?v=p8Ov-egc8hU](https://www.youtube.com/watch?v=p8Ov-egc8hU(a)
<script>
const request = require(‘request’);
function company(){
try{
const companies = await request({
method: ‘GET’,
url: `https://api.hubapi.com//companies/v2/companies/paged\`,
qs: { hapikey: `aaaaa`, count: 100, }, json: true });
document.getElementById(‘result1’).innerHTML = companies;
}
</script>
<button type=“button” onclick=“company();”>Click Me!</button> <p><span id=“result1”> </span></p>
------------------------
And I need to add three filter criteria and then pull the data based on it. So I am not sure how to use API without Javascript.
Thank you!!
Mansi
@mansigovani Yes, unfortunately, due to security reasons, a multitude of Hubspot’s APIs can’t be used directly on Hubspot because they’d either need to be written in something other than Javascript or use Ajax with CORS (which Hubspot doesn’t allow to be set). You would need to make the request to the API on an external site.