阅读背景:

Nodejs如何让api调用异步读取文件

来源:互联网 

This is my first nodejs project and I am still trying to get the hang of asynchronous calls so please bear with me. So in my routes I have registered '/users/username' to a function which will read a file (ideally a database but for now I am reading from a file). Now I have an option to call fs.readFileSync which I want to avoid. How do I pass a callback to fs.readFile which will then send the response back to the client? This is my first nodejs project and I am still




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: