promise

pixgram·2022년 6월 18일
0

fetch

fetch(`https://api.github.com/users/id)
	.then(response => response.json())
	.then(console.log)
	.catch(console.error)

async await

async function requestGithubUser(id) {
	try {
		const response = await fetch(`https://api.github.com/users/${id}`);
		const userData = await response.json();
		console.log(userData)
	} catch(error) {
		console.log(error)
	}
}
profile
interactive front-end developer

0개의 댓글