📅  最后修改于: 2022-03-11 14:56:52.889000             🧑  作者: Mango
fetch('https://api.github.com/users/{YOUR_USERNAME}', {
2 headers: {
3 'Accept' : 'application/vnd.github.v3+json'
4 }})
5 .then(response => response.json()) //Converting the response to a JSON object
6 .then( data => {
7 const root = document.querySelector('#root');
8 root.innerHTML = `
9 Name: ${data.name}
10 Followers: ${data.followers}
11 `
12 })
13 .catch( error => console.error(error));