floBlockchainAPI v3.0.1a

- Fixed: readTx and all its dependencies not having txs property when address (floID) doesnt have any tx
This commit is contained in:
sairajzero 2023-07-05 13:35:07 +05:30
parent 5398fcbbbc
commit e120b657da

View File

@ -1,4 +1,4 @@
(function (EXPORTS) { //floBlockchainAPI v3.0.1 (function (EXPORTS) { //floBlockchainAPI v3.0.1a
/* FLO Blockchain Operator to send/receive data from blockchain using API calls via FLO Blockbook*/ /* FLO Blockchain Operator to send/receive data from blockchain using API calls via FLO Blockbook*/
'use strict'; 'use strict';
const floBlockchainAPI = EXPORTS; const floBlockchainAPI = EXPORTS;
@ -802,9 +802,11 @@
if (options.confirmed) //Default is false in server, so only add confirmed filter if confirmed has a true value if (options.confirmed) //Default is false in server, so only add confirmed filter if confirmed has a true value
query_params.confirmed = true; query_params.confirmed = true;
promisedAPI(`api/address/${addr}`, query_params) promisedAPI(`api/address/${addr}`, query_params).then(response => {
.then(response => resolve(response)) if (!Array.isArray(response.txs)) //set empty array if address doesnt have any tx
.catch(error => reject(error)) response.txs = [];
resolve(response)
}).catch(error => reject(error))
}); });
} }