res.sendfile in Node Express with passing data along

前端 未结 6 1647
失恋的感觉
失恋的感觉 2020-12-01 10:35

Is there any way to redirect to an HTML file from a Node.JS application with something like: res.sendFile of express and pass a JSON data along to the html file?

6条回答
  •  醉梦人生
    2020-12-01 11:09

    You only have one response you can return from the server. The most common thing to do would be to template your file on the server with nunjucks or jade. Another choice is to render the file on the client and then to use javascript to make an ajax call to the server to get additional data. I suppose you could also set some data in a cookie and then read that on the client side via javascript as well.

提交回复
热议问题