0

so I have this Object, which when I console.log it and look at it in the inspector looks just fine. Object in Inspector

But when I print out the keys of the object, I only get this as a result: Object Keys in Inspector

And everything I print out after that (object.value) looks something like this:

ƒ (){return f&&(c&&!b&&(h=f.length-1,g.push(c)),function d(b){r.each(b,function(b,c){r.isFunction(c)?a.unique&&j.has(c)||f.push(c):c&&c.length&&"string"!==r.type(c)&&d(c)})}(arguments),c&&!b&&i()),this}

How can I access just the "responseJSON" from the first screenshot?

Some Background information that might be important: I got the object from the spotify web-api, authorization etc. works all just fine.

function getUserData(accessToken) {
        return $.ajax({
            url: 'https://api.spotify.com/v1/me/player/currently-playing',
            headers: {
               'Authorization': 'Bearer ' + accessToken
            }
        });
    }
1
  • Try 'object.responseText' Commented Nov 25, 2017 at 22:25

1 Answer 1

1

This is because your are enumerating a jQuery deferred object properties. Deferred objects are asynchronous, in your case coming from an HTTP request.

To properly enumerate over your object you should first wait for it to be available using Deferred.then. Replace your code from :

console.log(Object.keys(your_object))

to :

your_object.then(function(result) {
    console.log(Object.keys(result))
}).catch(function(err) {
    console.error(err)
})
Sign up to request clarification or add additional context in comments.

Comments

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.