my code at first is correct but with this error spread.js.25 I can not see result in the browser

350 Views Asked by At

When I inspect the code in the browser this error appears spread.js.25 and I can not find this problem.

I checked the exercise solution, it's the same as my solution ... I don't know much about axios ...

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Exercício 02</title>
</head>

<body>
  <input type="text" name="user">
  <button onclick="listRepositories()">Adicionar</button>

  <ul></ul>

  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  <script>
    var listElement = document.querySelector('ul');
    var inputElement = document.querySelector('input');
    function renderRepositories(repositories) {
      for (repo of repositories) {
        const textElement = document.createTextNode(repo.name);
        const liElement = document.createElement('li');
        liElement.appendChild(textElement);
        listElement.appendChild(liElement);
      }
    }
    function listRepositories() {
      var user = inputElement.value;
      if (!user) return;
      axios.get('https://api.github.com/users/' + user + '/repos')
        .then(function (response) {
          renderRepositories(response.data);
        })
    }
  </script>
</body>

</html>

this image is exactly the problem

0

There are 0 best solutions below