4
在鐵軌我做一個POST請求到我的服務器通過PARAMS:Node.js的:閱讀的URL
response = Typhoeus::Request.post("http://url.localtunnel.com/request?from=ola&to=ole")
result = JSON.parse(response.body)
在Node.js的應用程序,我想讀From
和To
:
app.post '/request', (req,res) ->
console.log "I have received a request, sweet!!"
sys.log req.params.from
#sys.log "From: " + req.from + ", To: " + req.to + ", Id: " + req.id
我該怎麼做?
感謝
右鍵,Express中的'params'是從您定義的路由中解析出來的,例如, 'app.get('/ user /:id',...'給你一個'req.param.id',你想要'req.query'。注意這裏並不重要,它是'GET'或'POST'請求。 –