Page 71 - Nodejs 교과서 개정2판
P. 71
axios.getب ղࠗী new Promiseо ٜয ਵ۽ thenҗ catchܳ ࢎਊೡ ࣻ णפ result.dataীח ࢲ
ߡ۽ࠗఠ ࠁմ ؘఠо ٜয णפ ח ѐߊ بҳ Console చীࢲ ഛੋೡ ࣻ णפ
۽झ۽ BTZOD await ߑधਵ۽ ߸҃ೡ ࣻ णפ ݺ ೣࣻۄࢲ द प೯ਸ ਤ೧ ٘ܳ ࣗҚഐ۽
хऱࢲ ഐ೮णפ
(async () => {
try {
const result = await axios.get('https://www.zerocho.com/api/get');
console.log(result);
console.log(result.data); // {}
} catch (error) {
console.error(error);
}
})();
ߣীח 1045 ߑध ਃਸ ࠁղѷणפ 1045 ਃীࢲח ؘఠܳ ࢲߡ۽ ࠁյ ࣻ णפ
(async () => {
try {
const result = await axios.post('https://www.zerocho.com/api/post/json', {
name: 'zerocho',
birth: 1994,
});
console.log(result);
console.log(result.data); // {}
} catch (error) {
console.error(error);
}
})();
ੋ ҳઑח ࠺तೠؘ ف ߣ૩ ੋࣻ۽ ؘఠܳ ֍য ࠁղח Ѫ ܵפ (&5 ਃݶ axios.getਸ P
OST ਃݶ axios.postܳ ࢎਊפ
ਵ۽ ࢲߡী ಬ ؘఠܳ ࠁղח ҃ܳ ঌইࠁѷणפ
'PSN%BUB