I tried getting balance of my stellar account after generating key pairs using the following code:
const server = new StellarSdk.Server("https://horizon-testnet.stellar.org");
// the JS SDK uses promises for most actions, such as retrieving an account const account = await server.loadAccount(pair.publicKey()); console.log("Balances for account: " + pair.publicKey()); account.balances.forEach(function (balance) { console.log("Type:", balance.asset_type, ", Balance:", balance.balance); });
The error I'm getting is this: (node:6622) UnhandledPromiseRejectionWarning: NotFoundError: Not Found at NotFoundError.NetworkError [as constructor] (/home/ashwin/stellar/node_modules/stellar-sdk/lib/errors.js:11:24) at new NotFoundError (/home/stellar/node_modules/stellar-sdk/lib/errors.js:29:24) at /home/stellar/node_modules/stellar-sdk/lib/call_builder.js:255:55 at step (/home/stellar/node_modules/tslib/tslib.js:141:27) at Object.next (/home/stellar/node_modules/tslib/tslib.js:122:57) at /home/stellar/node_modules/tslib/tslib.js:115:75 at new Promise () at Object.__awaiter (/home/stellar/node_modules/tslib/tslib.js:111:16) at CallBuilder._handleNetworkError (/home/stellar/node_modules/stellar-sdk/lib/call_builder.js:250:24) at
Why is this error occuring and how can it be resolved?