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җ э਷ ݽন੉ ؾפ׮  ࢲݺػ ௢ఃח
   215   216   217   218   219   220   221   222   223   224   225