-2
/*Create a screen with one that should be named after a user on Github. After typing the user name and click the search button the application should search for the Github API (as per URL below) the user repositories data and show them on screen: Example URL: https://api.github.com/users/diego3g/repos Just change "diego3g" by user name. Add After filling in the input and adding, the following list should appear below:
- repo1
- repos2
- repos 3
- repos4
- repos5
*/
<meta charset="UTF-8">
<title>Curso Java Script</title>
<div id="app">
<input type = "text" name = "user"/>
<button onclick="adicionar()">Adicionar</button>
<ul>
<li></li>
</ul>
</div>
<script src="https://unpkg.com/axios/dist/axios.js"></script>
<script src="exercicio2.js"></script>
var receivedInput = Document.querySelector('#app input'); var booBotao = Document.querySelector('#app button'); var booUl = Document.querySelector('#app ul');
Function fill(fill in){
var login2 = recebeInput.value;
for(repositorio of preenchimento){
var elementoT = document.createTextNode(repositorio.login2);
elementoL = document.createElement('li');
elementoL.appendChild(elementoT);
recebeUl.appendChild(elementoL);
}
}
Function storageSite(login){
if(!login) return;
axios.get('https://api.github.com/users/' + login + '/repos')
.then(function(response){
preenchimento(response.data);
})
.catch(function(error){
console.log('Deu erro');
})
}
Function add(){
var login = recebeInput.value;
console.log(login);
var requisicao = new XMLHttpRequest();
requisicao.open('GET', 'https://api.github.com/users/' + login + '/repos');
requisicao.send(null);
requisicao.onreadystatechange = function(){
if(requisicao.readyState === 4){
if(requisicao.status === 200){
armazenandoSite(login);
}
else{
console.log('Algo deu errado');
}
}
}
}
Where is an error message? What is the message?
– Romeu Gomes - Brasap
Error like this does not think it is logical error because it is not pulling the data to be printable on screen.
– Wellington Martins