J
J
Joiromay2021-10-23 14:05:39
JavaScript
Joiromay, 2021-10-23 14:05:39

How to parse data from JSON response?

I do not understand how to display this in the DOM https://jsonplaceholder.typicode.com/users/1
Here is my GET request:

var log = new XMLHttpRequest()
log.open(
    'GET',
    'https://jsonplaceholder.typicode.com/users/1',
    true
  )
  
  log.onreadystatechange = function() {
    if (log.readyState != 4) {
      return
    }
    if (log.status === 200) {
        let response = JSON.parse(log.responseText );
      } 
    }
    
log.send();

It should turn out something like this:
6173ec0045c5c966525328.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2021-10-23
@Joiromay

For inspiration:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question