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>