Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Json data in google chrome looking like a large string

Whenever I look into the Json data that comes back as a response i see it as a large string.
What do I have to do to see the data as a tree?
How my response looks like
How I want it

const request = new XMLHttpRequest;

request.addEventListener('readystatechange', () => {
    //if request state is valid (4)
    if(request.readyState === 4){
        console.log(request, request.responseText);
    }
});

//create request with the 'GET'.
request.open('GET', 'https://jsonplaceholder.typicode.com/todos/');
request.send();

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

First, you need to parse the data :

const result = json.parse(request.responseText);

The parsing process will ignore the \n

then you can properly log the json object as such :

console.log(result, null, 2);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading