bent icon indicating copy to clipboard operation
bent copied to clipboard

feat(bent): add http request timeout option for nodejs

Open mcgradycchen opened this issue 5 years ago • 0 comments

fix: #59 #104

I want to add a timeout option for nodejs http request.

The usage will be

const req = bent('GET', 200, 201);
req.timeout = 1000 * 10;
(async () => {
    await req('http://192.123.21.12/hello', null, null);
})();

@mikeal Please ignore the whitespace changes for this PR

image

Under the strict mode, we cannot use the assigned currying arrow function chain

'use strict'
const b = () => req = () => {
  return new Promise((resolve, reject) => {
    console.log(req.data)
    resolve(1)
  })
}

Then, have to change to the following explicitly way, tha't why so many whitespace changes

'use strict'
const b = () => {
  const req = () => {
    return new Promise((resolve, reject) => {
      console.log(req.data)
      resolve(1)
    })
  }
  return req
}

Thanks, McGrady

mcgradycchen avatar Dec 07 '20 08:12 mcgradycchen