14 lessons
The Certificate
After installing the module you can declare it by using the require() method depicted below.
But sometimes, inputting a URL and a callback function is all you need to make a request. Running the code would perform an HTTP GET request to the defined URL, and collect data in the callback function.
Another method would be utilizing an options object :
‣uri or url — A qualified URI or a parsed URL object from url.parse().
‣ method — HTTP method; defaults to GET.
‣headers — HTTP headers; defaults to {}.
‣qs — A name-value pair to be appended as a query string into the URL.’
‣body — A request body for POST and PUT requests.
‣form — Sets the body to a query-string representation of the value and adds the contenttype application utf-8 to the header.
‣json — Sets the body to a JSON representation of the value and adds the content-type application/json header.