Skip to content

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

Open
mcgradycchen wants to merge 3 commits into
mikeal:masterfrom
mcgradycchen:feature/node-http-timeout
Open

feat(bent): add http request timeout option for nodejs#132
mcgradycchen wants to merge 3 commits into
mikeal:masterfrom
mcgradycchen:feature/node-http-timeout

Conversation

@mcgradycchen

@mcgradycchen mcgradycchen commented Dec 7, 2020

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose options for underlying http client

1 participant