javascript - How to request the API interface to get data in node?
欧阳克
欧阳克 2017-06-13 09:23:57
0
2
884

I want to request the interface data in nodeJs and then render it with ejs, so that when the browser requests it, the front-end page will be the rendered page. How to do this? (This seems to be a step towards separating the front and back ends)

欧阳克
欧阳克

温故而知新,可以为师矣。 博客:www.ouyangke.com

reply all(2)
我想大声告诉你

Using the EJS template engine does not require requesting the interface, it is directly rendered, and the backend directly transmits the output

//JS:
res.render('home', //这是你EJS模板页面的名称
{title: 'home'});

//html取值:
<%=title %>
漂亮男人

Use node to request the interface? superagent

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template