NodeJS实现同步http请求

npm install -g xd-synchttp

安装完成后,示例代码如下。

const sync = require('xd-synchttp');

let content = "";

try{

    content = sync.http_get('http://www.csdn.net',0);

//0为不超时,其他数值为超时秒数

}

catch(err)

{

console.log(err);

}



猜你喜欢

转载自blog.csdn.net/haojingus/article/details/80326905