You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I came across this issue while coding a script that updates a local JSON file holding all the transactions of our Pool Operator. The script checks how many transactions I already saved in a JSON and how many are left to fetch. But after I downloaded 30 transactions, I was missing the latest 3 transactions I broadcasted. Upon debugging, I noticed that the total value changes from 30 to 0 if I add any offset parameter to the request.
It would be great to always show the total amount of transactions so developers can use a while loop to fetch up until total has been reached.
letlastTxs=[];lettotal=0;letlimitLastTxs=10;lettotalSavedTxs=jsonTxData.transactions.length;letoffsetLastTxs=jsonTxData.transactions.length;while(total<=totalSavedTxs){try{awaitfetch('https://api.hiro.so/extended/v2/addresses/'+poolAddress+'/transactions?limit='+limitLastTxs+'&offset='+offsetLastTxs,{method: 'get',headers: {'Content-Type': 'application/json'}}).then((response)=>response.json()).then((data)=>{//console.log('data', data);// Concatenate results with the previous fetchlastTxs=lastTxs.concat(data.results);// Update totaltotal=data.total;// Update offsetoffsetLastTxs=(lastTxs.length+totalSavedTxs);});// Break if it is still totalSavedTxs === totalif(total===totalSavedTxs||total===0)break;}catch(e){console.error('Could not fetch transactions from HIRO API.');thrownewError(e);}}
Example: https://api.hiro.so/extended/v2/addresses/SP1JX8274K2R0MMP1VCX56C5DCERPP6EH5XHS68MR/transactions?limit=30&offset=30
When
offset=
is removed:The text was updated successfully, but these errors were encountered: