如何从节点响应对象获取请求URL?

编程入门 行业动态 更新时间:2024-10-10 04:28:26

如何从<a href=https://www.elefans.com/category/jswz/34/1771452.html style=节点响应对象获取请求URL?"/>

如何从节点响应对象获取请求URL?

[当您使用Node发出http / https请求(或使用诸如simple-get的包装器)时,您将返回simple-geterrresponse对象。在回调中,有没有办法获取原始请求的URL,主机,URL等?

示例(使用data):

simple-get's concat
回答如下:

您可以从基础套接字(由于[C​​0]只是包装simple-get-模块的包装器)和const get = require('simple-get') get.concat('http://example', function (err, res, data) { if (err) throw err console.log(res.statusCode) // 200 console.log(res.headers) // {...} // i want "http://example" at this point console.log(res.uri) // undefined console.log(res.url) // undefined console.log(res.path) // undefined console.log(res.host) // undefined }) -对象获得一些信息:

simple-get

更多推荐

如何从节点响应对象获取请求URL?

本文发布于:2024-05-07 03:57:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1754235.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:节点   对象   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!