Page 470 - Nodejs 교과서 개정2판
P. 470

$034 ੉೧ೞӝ







         ੉੹ ੺ীࢲ /PEF$BU੉ OPEFCJSE BQJܳ ഐ୹ೞח Ѫ਷ ࢲߡীࢲ ࢲߡ۽ "1*ܳ ഐ୹ೠ Ѫੑפ׮  ݅ড /PEF
         $BU੄ ೐۠౟ীࢲ OPEFCJSE BQJ੄ ࢲߡ "1*ܳ ഐ୹ೞݶ যڌѱ ؼөਃ

         SPVUFT JOEFY KTী ೐۠౟ ചݶਸ ۪؊݂ೞח ۄ਋ఠܳ ୶о೤פ׮


          nodecat/routes/index.js

           ...
           router.get('/',	(req,	res)	=>	{
           		res.render('main',	{	key:	process.env.CLIENT_SECRET	});
           });


           module.exports	=	router;



         ೐۠౟ ചݶب ୶о೤פ׮


          nodecat/views/main.html
           <!DOCTYPE	html>
           <html>
           		<head>
           				<title>프런트	API	요청</title>
           		</head>
           		<body>
           		<div	id="result"></div>
           		<script	src="https://unpkg.com/axios/dist/axios.min.js"></script>
           		<script>
           				axios.post('http://localhost:8002/v2/token',	{
           						clientSecret:	'{{key}}',
           				})
           						.then((res)	=>	{
           								document.querySelector('#result').textContent	=	JSON.stringify(res.data);
           						})
           						.catch((err)	=>	{
           								console.error(err);
           						});
           		</script>
           		</body>
           </html>
   465   466   467   468   469   470   471   472   473   474   475