Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

github API fetch

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                      <a href="${data.html_url}">Name: ${data.name}</a>
10                     <p>Followers: ${data.followers}</p>
11                  `
12                })
13		.catch( error => console.error(error));
Source by www.pluralsight.com #
 
PREVIOUS NEXT
Tagged: #github #API #fetch
ADD COMMENT
Topic
Name
3+8 =