How do I chain qbo3 API calls as promises in Javascript?
I’m trying to get the JavaScript below to pause after hitting var api
until var data
has been completed. Then after being completed, the function can continue on as usual. The overall goal being to get an approx. measure of how long it is taking for the query to run after being called on through the function call.
var data = {...};
var api1 = new qbo3.ProcessObject();
api1.invokeJson('StartRecordingTime',data);
var api2 = new qbo3.ProcessObject({target: 'row_4'});
api2.invokeHtml('RealWorldApiCall', data);
var api3 = new qbo3.ProcessObject();
api3.invokeJson('EndRecordingTime');
You can construct a promise based on a qbo3 API call as follows:
where:
cn
: is the className of the API endpoint (e.g.Process
,Loan
,Person
,Message
, etc.)method
: is the class method to be invoked (e.g.Select
,Search
,Update
, etc.)data
: is theJSON
data to be submittedThen you can use:
More generic usage leveraging the results of one API for the data being passed to a subsequent call:
Note that if you're just troubleshooting response times,
qbo3
includes anX-Execution-Time
response header all API calls. This header is not passed to theresolve
method, you can inspect it from Chrome's developer console'sNetwork
table, pictured here: