0

My code is

const api = new RippleAPI({
  server: 'wss://s1.ripple.com'
});

api.connect();

    let isConnected = false;
    api.on('connected', () => {
      isConnected = true;
    });
      return api.getTransactions(address)
        .then((transactions) => {
          console.log(transactions);
        })
        .catch((err) => {
          console.log(err);
        })

But it doesn't actually return anything. It has an empty array [] for transactions.

If you look at the address I'm looking at: https://xrpcharts.ripple.com/#/graph/rqnfXCcsZRadjoj8tDQWYsP1pVyv3Ro7X

You'll see there are some transactions. So why doesn't the API return anything?

1

You can use chain of promises like this:

const RippleAPI = require('ripple-lib').RippleAPI; var test_server = 'wss://s2.ripple.com'; const api = new RippleAPI({ server: test_server // Public rippled server }); api.connect().then(() => { /* begin custom code ------------------------------------ */ const myAddress = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn'; console.log('getting account info for', myAddress); return api.getTransactions(myAddress); }).then(info => { console.log(info); /* end custom code -------------------------------------- */ }).then(() => { return api.disconnect(); }).then(() => { console.log('done and disconnected.'); }).catch(console.error);

Good luck)

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.