I'm new to javascript and am trying to query some blockchain data. I can query the data successfully when just querying once. But I would like to do this continuously.
When I use the while loop in an effort to continually run the query, it retrieves no data.
I've tried using a for loop with a range of 100, and see that it seems to wait until all 100 data points are found before returning.
I'm assuming it's doing something similar with my while loop and thus not returning anything because of its infinite nature. I've done this in python but seem to have issue with javascript.
My code is below.
const { LCDClient } = require('@terra-money/terra.js');
const terra = new LCDClient({
//URL: 'https://bombay-lcd.terra.dev',
//chainID: 'bombay-12',
URL: 'https://lcd.terra.dev',
chainID: 'columbus-5'
});
const contract = 'terra1a8k3jyv3wf6k3zngza5h6srrxcckdf7zv90p6u';
const pair_address = 'terra19l0hnypxzdrp76jdyc2tjd3yexwmhz3es4uwvz';
const query_msg = {"simulation": {"offer_asset": {"amount": "1", "info": {"token": {"contract_addr": contract}}}}};
while (true) {
terra.wasm.contractQuery(pair_address, query_msg).then(result => {
console.log(result);
})
}