Skip to main content
Question

Displaying reports on web pages using Javascript

  • September 8, 2020
  • 0 replies
  • 60 views

Forum|alt.badge.img+3
I will start by admitting that I am not a "real" developer :).  I have been working with the new RESTful API (thanks to Harrison) and I've been able to get a Success (200) within the QB API Portal; however, I can figure out how to embed the Javascript into a plain HTML page to render the report.  I can worry about formatting and CSS later, I presume, but I just want to be able to test it and see the data first.  I am just using ATOM to create the index.html page and I'm using XAMMP for the localhost.  Can someone share with me how I would format the html to embed the following javascript code:


var headers = {
'QB-Realm-Hostname': 'xxxxxxxxxx',
'User-Agent': '{User-Agent}',
'Authorization': 'QB-USER-TOKEN xxxxx_xxxx_xxxxxxxxxxxxxxxxx',
'Content-Type': 'application/json'
}


const xmlHttp = new XMLHttpRequest();
xmlHttp.open('POST', 'https://api.quickbase.com/v1/reports/10/run?tableId=xxxxxxxx&skip={skip}&top={top}', true);
for (const key in headers) {
xmlHttp.setRequestHeader(key, headers[key]);
}
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState === XMLHttpRequest.DONE) {
console.log(xmlHttp.responseText);
}
};

xmlHttp.send();

------------------------------
Myoshia Boykin-Anderson
------------------------------
This topic has been closed for replies.

Forum|alt.badge.img+11
  • Quickbase Staff
  • September 8, 2020
Hi Myoshia! Thanks for the shout-out! First thing is, you don't want to store a usertoken in JavaScript. That isn't a security best practice. We provide a temp authorization endpoint to help you with that. Take a look at this sample app we created that illustrates both a database page and temporary tokens and see if it helps.

------------------------------
Harrison Hersch
------------------------------