0
サンプルコード:サーバー側のAPIからデータを取得し、取得したデータをexpressjsを使用してpugjsファイルに渡す方法はありますか?
// index.pug
p #{polls}
// apiendpoint
http://localhost:8080/api/polls
// routesファイル(index.js):ここで
、私はどのように行いますapiにリクエストを行い、プロファイルをレンダリングしながらapi(locals)の検索結果を変数pollsに渡します。
app.route('/profile')
.get(isLoggedIn, function (req, res) {
res.render('profile', {'polls': passvaluehere});
});
});