从服务器主动发送请求
从服务器主动发送请求调用接口-查询数据
const http = require('http');
//這是已知的并且已經存在的服務器 ---【獲取展示目錄下的頁面】
let option = {
protocol:'http:',
hostname:'localhost',
port:3000,
path:'/'
}
let req = http.request(option,(res)=>{
let info = '';
res.on('data',(chunk)=>{
info += chunk;
});
res.on('end',()=>{
console.log(info);
})
});
req.end();
从服务器主动发送请求调用接口-添加数据
const http = require('http');
const querystring = require('querystring');
let options = {