1
async.series([
function(callback){
            geen.api('OpenOrders', function(error, data) {
            callback(null, data.result['open']);
            if(error) {
            console.log(error);
             }


            });
            }   
],
function(err, results){
    console.log(results[0]['OJVBCE-KZ7SX-SNNAAP'].status) // undefined


});
});

returns this json:

    [{ 'OJVBCE-KZ7SX-SNNAAP':
             {  refid: null,
                userred: null,
                status: 'open',
                opentm: 1397461378.8155
             }
    }]

How do I acces this? For example: results['OJVBCE-KZ7SX-SNNAAP'].status I get an undefined.

2
  • Please console.log(results) and tell me what you have there Commented Apr 14, 2014 at 9:59
  • you should also fix your question to have results[0]['OJVBCE-KZ7SX-SNNAAP'].status Commented Apr 14, 2014 at 10:00

1 Answer 1

1

It's an array and OJVBCE-KZ7SX-SNNAAP is at the first position so:
results[0]['OJVBCE-KZ7SX-SNNAAP'].status

if you would like to access it the way you show you would have to have the array formed like this:

var results = [];  
results['OJVBCE-KZ7SX-SNNAAP'] = {  
    refid: null,  
    userred: null,  
    status: 'open',  
    pentm: 1397461378.8155  
}

Now results['OJVBCE-KZ7SX-SNNAAP'].status will work

Sign up to request clarification or add additional context in comments.

1 Comment

Maybe I did not show enough code in my question. I added some more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.