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();
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);