I recently started doing react native and don't understand as how to debug so as to get my results in console . Here is the result I get in console .
Organizations is [object Object]
How do i get all the content of organizations . I did this in my code for console .
console.log('Organizations is '+organizations);
For the android emulator, Click on the emulator screen and Press Control + M ( Ctrl + M ), After open the dialog option select Remote JS Debugging. This will open a resource, http://localhost:8081/debugger-ui on localhost. From there, use the Chrome Developer tools JavaScript console to view console.
Answer: Use console. log() or JSON. stringify() Method You can use the console. log() method, if you simply wants to know what's inside an object for debugging purpose. This method will print the object in browser console.
React Practice Course. We will import List in our Home component and show it on screen. To create a list, we will use the map() method. This will iterate over an array of items, and render each one. When we run the app, we will see the list of names.
You can stringify it.
console.log(JSON.stringify(organizations));
if you want some formatting
console.log(JSON.stringify(organizations, null, 2));
Here are all methods to print an object without going mad. Print object in JavaScript
console.log('Organisations is : ' + JSON.stringify(organisations));
Most consoles look at the argument they're passed and show an intelligent rendering of it, so you may want to provide organizations
directly rather than concatenating it with a string (which will invoke the object's default toString
behavior, which is "[object Object]"
if you haven't done something special). Most also support multiple arguments, so you can do
console.log("Organizations is", organizations);
...to see both your label and the intelligent rendering.
See also this question's answers about console rendering, though.
In ES6 syntaxe you can do something like this :
console.log(`Organisations is : ${JSON.stringify(organisations)}`);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With