32 lines
759 B
JavaScript
32 lines
759 B
JavaScript
|
'use strict';
|
||
|
|
||
|
const bhttp = require('bhttp');
|
||
|
|
||
|
const sleep = 5000;
|
||
|
const timeout = 1000;
|
||
|
|
||
|
async function init() {
|
||
|
try {
|
||
|
const res = await bhttp.get(`https://httpstat.us/200?sleep=${sleep}`, {
|
||
|
responseTimeout: timeout,
|
||
|
});
|
||
|
|
||
|
console.log(res.statusCode);
|
||
|
} catch (error) {
|
||
|
console.log(error);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
/home/pendulum/projectx/node_modules/bhttp/lib/bhttp.js:159
|
||
|
err.response = response;
|
||
|
^
|
||
|
|
||
|
TypeError: Cannot assign to read only property 'response' of object '[object Object]'
|
||
|
at addErrorData (/home/pendulum/projectx/node_modules/bhttp/lib/bhttp.js:159:16)
|
||
|
at Timeout.timeoutHandler [as _onTimeout] (/home/pendulum/projectx/node_modules/bhttp/lib/bhttp.js:525:27)
|
||
|
*/
|
||
|
|
||
|
|
||
|
init();
|