-
Notifications
You must be signed in to change notification settings - Fork 396
Refactored the HTTP Client Implementation #483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…-node into hkj-http-cleanup
src/utils/api-request.ts
Outdated
} | ||
reject(enhanceError(err, config, null, req)); | ||
}); | ||
constructor(config: HttpRequestConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to declare this as private since it is pretty much only initialized from within the static method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Done.
src/utils/api-request.ts
Outdated
throw new Error('Request data must be a string, a Buffer or a json serializable object'); | ||
} | ||
|
||
// Add Content-Length header if data exists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Thanks @bojeil-google. I've made the suggested changes. |
This code has become rather long and complex over the months. Therefore I'm refactoring it to make the code more modular and easier to follow:
AsyncHttpCall
class to handle a single HTTP interaction.sendRequest()
method has been broken down into a bunch of smaller methods, and moved intoAsyncHttpCall
.