阿西河 博客 Node.js 做中间件转发资源给前端 Node.js 做中间件转发资源给前端 0001年1月1日 1 分钟阅读 使用 HTTP/https 做为客户端请求资源,引用核心模块http 或 https node 模拟一个客户端,请求资源;(请求后可以转给前端) 1 2 3 4 5 6 7 8 9 10 11 12 13 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)) }) }); Node.js rgpc 通信demo Node.js 入门
使用 HTTP/https 做为客户端请求资源,引用核心模块http 或 https node 模拟一个客户端,请求资源;(请求后可以转给前端) 1 2 3 4 5 6 7 8 9 10 11 12 13 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)) }) });