Page 72 - Nodejs 교과서 개정2판
P. 72
)5.- form కӒ ؘఠܳ زਵ۽ ઁযೡ ࣻ ח ӝמੑפ ۽ "+"9৬ ೣԋ ࢎਊؾפ
ݢ FormData ࢤࢿ۽ formData ёܳ ٟ݅פ ٘ܳ ೠ ঀ $POTPMF చী ੑ۱೧ࠁࣁਃ
const formData = new FormData();
formData.append('name', 'zerocho');
formData.append('item', 'orange');
formData.append('item', 'melon');
formData.has('item'); // true
formData.has('money'); // false;
formData.get('item'); // orange
formData.getAll('item'); // ['orange', 'melon'];
formData.append('test', ['hi', 'zero']);
formData.get('test'); // hi, zero
formData.delete('test');
formData.get('test'); // null
formData.set('item', 'apple');
formData.getAll('item'); // ['apple'];
ࢤࢿػ ё append ݫࢲ٘۽ ః ч ഋध ؘఠܳ ೡ ࣻ णפ append ݫࢲ٘ܳ ৈ۞ ߣ ࢎਊ೧ࢲ
ః ೞաী ৈ۞ ѐ чਸ ୶о೧ب ؾפ has ݫࢲ٘ח য ఃী ೧ೞח ч ח ৈࠗܳ ঌ݀פ H
FU ݫࢲ٘ח য ఃী ೧ೞח ч ೞաܳ оઉয়Ҋ getAll ݫࢲ٘ח ೧ೞח ݽٚ чਸ оઉ২פ delet
e ݫࢲ٘ח അ ఃܳ ઁѢೞח ݫࢲ٘Ҋ set അ ఃܳ ࣻೞח ݫࢲ٘ੑפ
ઁ axios۽ ಬ ؘఠܳ ࢲߡী ࠁղݶ ؾפ
(async () => {
try {
const formData = new FormData();
formData.append('name', 'zerocho');
formData.append('birth', 1994);
const result = await axios.post('https://www.zerocho.com/api/post/formdata', formData);
console.log(result);
console.log(result.data);
} catch (error) {
console.error(error);
}
})();
ف ߣ૩ ੋࣻী ؘఠܳ ֍য ࠁշפ അ ࢸػ ࣗח पઁ۽ زೞח ࣗۄࢲ ѾҞчਸ ߉ਸ ࣻ ण