Exercise: Request Builder

Practice how to create a Builder class around the built-in http.request() function.

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.

Coding challenge

Write your solution code in the following code widget. We’ve already added the package.json file for your ease.

Get hands-on with 1400+ tech skills courses.