Node.js 为什么控制台显示未定义??
我使用了.method来恢复,但是显示我未定义的控制台。。。。为什么?请帮忙Node.js 为什么控制台显示未定义??,node.js,google-api-nodejs-client,nodejs-stream,Node.js,Google Api Nodejs Client,Nodejs Stream,我使用了.method来恢复,但是显示我未定义的控制台。。。。为什么?请帮忙 const http = require('http'); http.createServer((req, res)=>{ console.log(res.method); }).listen(9111); 控制台显示的是未定义的,因为响应对象上没有定义的属性方法。与HTTP请求不同,HTTP响应没有方法类型 也许您正在寻找req.method?res.method(Response.method)不
const http = require('http');
http.createServer((req, res)=>{
console.log(res.method);
}).listen(9111);
控制台显示的是
未定义的
,因为响应对象上没有定义的属性方法
。与HTTP请求不同,HTTP响应没有方法类型
也许您正在寻找req.method
?res.method
(Response.method)不是Response
类的属性
您正在寻找
req.method
(您正在使用res.method
):
当访问
localhost:9111/
..@Viking_Castle时,即使您将其从res.method
更改为req.method
,也会打印“GET”?您所说的“我已使用了.method to res”是什么意思?您能否解释更多,并提供更多代码解释什么是方法?
const http = require('http');
http.createServer((req, res)=>{
console.log(req.method);
}).listen(9111);