Page 220 - Nodejs 교과서 개정2판
P. 220
ਃਸ ܻೡ ਃо ݶ CPEZ QBSTFSܳ ࢸೠ റ җ э ୶оפ
콘솔
$ npm i body-parser
const bodyParser = require('body-parser');
app.use(bodyParser.raw());
app.use(bodyParser.text());
ਃ ؘఠ ઙܨܳ рױ ಝࠇद +40/ +40/ ഋध ؘఠ ׳ ߑधҊ 63- FODPEFEח ࣗ ഋ
धਵ۽ ؘఠܳ ࠁղח ߑधੑפ ಬ ࣠ 63- FODPEFE ߑधਸ ۽ ࢎਊפ urlencoded ݫࢲ٘ܳ
ࠁݶ { extended: false }ۄח ২࣌ ٜয णפ ২࣌ falseݶ ֢٘ RVFSZTUSJOH ݽٕਸ ࢎਊೞৈ
௪ܻझ݂ਸ ೧ࢳೞҊ trueݶ RT ݽٕਸ ࢎਊೞৈ ௪ܻझ݂ਸ ೧ࢳפ RT ݽٕ ղ ݽٕ ইפۄ O
QN ಁఃݴ RVFSZTUSJOH ݽٕ ӝמਸ ખ ؊ ഛೠ ݽٕੑפ
ীࢲ 1045৬ 165 ਃ ࠄޙਸ ׳߉ਵ۰ݶ req.on('data')와 req.on('end')۽ झܿਸ ࢎਊ೧ঠ
೮؍ Ѫਸ ӝরೞաਃ CPEZ QBSTFSܳ ࢎਊೞݶ Ӓۡ ਃо হणפ ಁఃо ղࠗਵ۽ झܿਸ ܻ
೧ req.bodyী ୶оפ
ܳ ٜয +40/ ഋधਵ۽ { name: 'zerocho', CPPL: 'nodejs' }ܳ ࠄޙਵ۽ ࠁմݶ req.bodyী Ӓ۽
ٜযцפ 63- FODPEFE ഋधਵ۽ name=zerocho&book=nodejsܳ ࠄޙਵ۽ ࠁմݶ req.bodyী { name:
'zerocho', book: 'nodejs' }о ٜযцפ
DPPLJF QBSTFS
DPPLJF QBSTFSח ਃী زࠉػ ఃܳ ೧ࢳ೧ req.cookies ё۽ ٟ݅פ parseCookies ೣࣻ৬
ӝמ ࠺तפ DPPLJF QBSTFS ٜਝযח җ э ࢎਊפ
app.js
app.use(cookieParser(비밀키));
೧ࢳػ ఃٜ req.cookies ёী ٜযцפ ܳ ٜয name=zerocho ఃܳ ࠁչݶ req.cookiesח {
name: 'zerocho' }о ؾפ ਬബ ӝр դ ఃח ঌইࢲ Ѧ۞շפ
ߣ૩ ੋࣻ۽ ࠺ ఃܳ ֍য ࣻ णפ ࢲݺػ ఃо ח ҃ ઁҕೠ ࠺ ఃܳ ా೧ ೧ ఃо ղ
ࢲߡо ݅ٚ ఃਸ Ѩૐೡ ࣻ णפ ఃח ۄীࢲ ਤઑೞӝ ए۽ ࠺ ఃܳ ా೧ ٜ݅যմ
ࢲݺਸ ః ч ٍী ࠢੑפ ࢲݺ ࠢਵݶ ఃо name=zerocho.signҗ э ݽন ؾפ ࢲݺػ ఃח