Я использовал .method для разрешения, но консоль показывает мне undefined .... Почему ??помогите пожалуйста ??
const http = require('http'); http.createServer((req, res)=>{ console.log(res.method); }).listen(9111);
res.method (Response.Method) не является свойством класса Response.
res.method
Response
https://nodejs.org/api/http.html#http_class_http_serverresponse
Вы ищете req.method (вы используете res.method ...):
req.method
const http = require('http'); http.createServer((req, res)=>{ console.log(req.method); }).listen(9111);
Будет печатать «GET» при доступе к localhost:9111/ ...
localhost:9111/
Консоль показывает вам undefined, потому что нет определенного свойства method в объекте ответа. В отличие от HTTP-запросов, HTTP-ответы не имеют типа метода.
undefined
method
Возможно, вы искали req.method?