Search code examples
javascriptloggingpebble-js

How can I debug Objects in Pebble.js?


I'm fetching via ajax

ajax(
    {
        url: ...,
        type: 'json'
    },
    function(data) {
        // Success!
        console.log(data);
    },
    function(error) {
        // Failure!
    }
)

And I'm getting

[HANDY] pebble-app.js:?: [object Object]

If I know what attributes to look for, I can access them by data.key. But how about objects with unknown attributes or if I simply need deep debugging?


Solution

  • Use JSON.stringify so you can see the values of your object as a JSON string in the app log:

    console.log(JSON.stringify(data));
    

    Lot's of Pebble.js examples use that to debug.