async function getNewsAndWeatherAsync() {
// TODO: async/await 키워드를 이용해 작성합니다
let result1 = await fetch(newsURL).then(response => response.json());
let result2 = await fetch(weatherURL).then(response => response.json());
return {
news: result1.data,
weather: result2
}
}
if (typeof window === 'undefined') {
module.exports = {
getNewsAndWeatherAsync
}
}
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));
axios.post("url",data)
axios
.post('https://koreanjson.com/users', { nickName: 'ApeachIcetea', age: '20' })
.then((response) => {
const { data } = response;
console.log(data);
})
.catch((error) => console.log(error));
복습: spread, 구조분해할당, async/await > 암기