Node.js 做中间件转发资源给前端
🌙
手机阅读
本文目录结构
使用 HTTP/https 做为客户端请求资源,引用核心模块http
或 https
node 模拟一个客户端,请求资源;(请求后可以转给前端)
let https = require("https");
let url ='https://m.douban.com/rexxar/api/v2/muzzy/columns/10018/items?start=0&count=3';
https.get(url,function (res) {
let data= '';
res.on("data",function (p) {
data+=p;
})
res.on("end",function () {
console.log(JSON.parse(data))
})
});