A wrapper around the node https request method.
$ npm install --save https-service
const HttpsService = ;const service = 'httpbin.org';service;
The package exports the
HttpsService class. This class provides the
request method and various convenience methods that call the
request method. The
request method can be overridden in a subclass. One reason, for example, is adding header values. Be sure to call
super.request(...) when overriding this method.
Creates a new
HttpsService instance for the specified host. The
hostname can also be a complete URI if the port is not the default HTTPS port number (443). In that case, the scheme must be specified and it must be
const service = 'example.com';
const service = '';
Sends an HTTPS request to the host specified in the constructor.
methodshould be one of
DELETE. The method is converted to upper case.
pathidentifies the resource with respect to the host specified in the constructor.
headersmust be an object or
dataspecifies the message body and can be a
Buffer, a string, or an object. If the
dataparameter is an object, then it is processed as follows:
- If the
application/json, then the data is serialized by calling
- If the
application/x-www-form-urlencoded, then the data is serialized by calling
- If the
Content-Typeheader is not set, then the data is serialized by calling
Content-Typeheader is set to
- If the
Returns a promise that is resolved with an object having the following properties:
- code - the status code (e.g., 200)
- headers - a headers object
- type - the content-type header without parameters (e.g.,
- data - the received data
data will be a string if the
type begins with
text or ends with
+xml. It will be an object if the
application/json. Otherwise, the
data will be a
Buffer. Note that if the
code is 204 (No Content), then the
data will both be
null. Also, if the method is
HEAD, then the
data will be null.
3.3 get, head
Convenience methods for
HEAD requests. If the optional
query object is specified, it is serialized and appended to the
path preceded by a
?. If the
path already contains a query, then it is appended with a
3.4 post, put, patch
Convenience methods for the
Convenience method for the
3.6 Media Types
There are three static media type constants on the HttpsService class:
HttpsServiceJSON_MEDIA_TYPE = 'application/json';HttpsServiceFORM_MEDIA_TYPE = 'application/x-www-form-urlencoded';
The MIT License (MIT)
Copyright (c) 2018 Frank Hellwig
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.