Axios
μλ°μ€ν¬λ¦½νΈ
μμ μ§μνλ fetchμ λΉμ·ν μν μ νλ μ¨λνν° λΌμ΄λΈλ¬λ¦¬μ΄λ€.
npm install axios
import axios from 'axios';
// Promise ver
axios
.get('https://koreanjson.com/users/1')
.then((response) => {
const { data } = response;
console.log(data);
})
.catch((error) => console.log(error));
// Async / Await ver
// async function request() {
// const response = await axios.get('https://koreanjson.com/users/1');
// const { data } = response;
// console.log(data);
// }
// request();
const appDiv = document.getElementById('app');
appDiv.innerHTML = `
<h1>Axios βΊοΈ</h1>
<h3>console μ°½μ νμΈν΄μ£ΌμΈμ! πππ</h3>
`;