Exercise: Request Builder
Explore how to create a Builder pattern class to construct and execute HTTP requests in Node.js. Understand setting methods, URLs, headers, queries, and body data, and returning a promise-based invocation.
We'll cover the following...
We'll cover the following...
Problem statement
Create your own Builder pattern-based class around the built-in http.request() function. The builder must be able to provide at least basic facilities to specify the HTTP method, the URL, the query component of the URL, the header parameters, and the eventual body data to be sent. To send the request, provide an invoke() method that returns a Promise for the invocation.