search

Home  >  Q&A  >  body text

javascript - How to request the API interface to get data in node?

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)

欧阳克欧阳克2721 days ago891

reply all(2)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-06-13 09:25:57

    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 %>

    reply
    0
  • 漂亮男人

    漂亮男人2017-06-13 09:25:57

    Use node to request the interface? superagent

    reply
    0
  • Cancelreply