Generation

generate functionTue, 17 Jan 2023

fetch an api and populate in a div

const fetchJson = async () => { const response = await fetch('https://api.github.com/users/mattbajorek'); const data = await response.json(); const { name, html_url, location, bio } = data; const locationSpan = document.getElementById('location'); const profileLink = document.getElementById('profileLink'); const bioSpan = document.getElementById('bio'); locationSpan.innerText = location; profileLink.innerText = name; profileLink.href = html_url; bioSpan.innerText = bio; }; fetchJson();

TypeScript
Generate More

Questions about programming?Chat with your personal AI assistant