0

I'm using the Javascript SDK. My objective is to get the last 10 transactions for a given account (which is working), but just show specific fields (such as the amount of lumens, and perhaps the memo), on each row in the console (which I eventually want to show on an HTML page, but for now console output is ok while I get over this hurdle).

I have this function (based on one of the stellar.org examples):

function ShowTransactions(fromAccount) {
    // Shows a simple list of transactions for the given account
    server.transactions()
    .forAccount(fromAccount)
    .limit(10)
    .order('desc')
    .call()
    .then(function (page) {
        console.log('Page 1: ');
        console.log(page.records);
        return page.next();
    })
    .then(function (page) {
        console.log('Page 2: ');
        console.log(page.records);
    })
    .catch(function (err) {
        console.log(err);
    });
}

This outputs everything to the console, but I'm not sure how to just specify the specific fields I want to display. Is this something that is done by doing some properties of

console.log(page.records. ..(etc)

or do I need to do something different ?

Many thanks in anticipation

1

page.records is an array, you can loop through it like this:

page.records.forEach( function(record) {
    console.log("txId: " + record.id);
    console.log("created: " + record.created_at);
    // console.log( record.whatever)
});

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.