2020年3月4日 星期三

req與res在node.js的意思

在node.js裡面跟網頁互動的話,
通常會有call back function,
而call back function通常會有兩個參數,
一個是req
一個是res

根據Express API這一個網站說明

Request
The req object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on. In this documentation and by convention, the object is always referred to as req (and the HTTP response is res) but its actual name is determined by the parameters to the callback function in which you’re working.

Response
The res object represents the HTTP response that an Express app sends when it gets an HTTP request.

參考資料:
Express API

沒有留言: