http-call

  • Version 5.3.0
  • Published
  • 43.9 kB
  • 6 dependencies
  • ISC license

Install

npm i http-call
yarn add http-call
pnpm add http-call

Overview

make http requests

Index

Classes

class HTTP

class HTTP<T> {}
  • Utility for simple HTTP calls

constructor

constructor(url: string, options?: Partial<any>);

    property body

    body: {};

      property ctor

      readonly ctor: typeof HTTP;

        property defaults

        static defaults: Partial<any>;

          property headers

          readonly headers: any;

            property method

            readonly method: string;

              property options

              options: any;

                property partial

                readonly partial: boolean;

                  property request

                  request: any;

                    property response

                    response: any;

                      property secure

                      readonly secure: boolean;

                        property statusCode

                        readonly statusCode: number;

                          property url

                          url: string;

                            method create

                            static create: (options?: HTTPRequestOptions) => typeof HTTP;

                              method delete

                              static delete: <T>(
                              url: string,
                              options?: HTTPRequestOptions
                              ) => Promise<HTTP<T>>;
                              • make an http DELETE request

                                Parameter url

                                url or path to call

                                Parameter options

                                Returns

                                {Promise}

                                Example 1

                                const http = require('http-call')
                                await http.delete('https://google.com')

                              method get

                              static get: <T>(url: string, options?: HTTPRequestOptions) => Promise<HTTP<T>>;
                              • make an http GET request

                                Parameter url

                                url or path to call

                                Parameter options

                                Returns

                                {Promise}

                                Example 1

                                const http = require('http-call')
                                await http.get('https://google.com')

                              method patch

                              static patch: <T>(url: string, options?: HTTPRequestOptions) => Promise<HTTP<T>>;
                              • make an http PATCH request

                                Parameter url

                                url or path to call

                                Parameter options

                                Returns

                                {Promise}

                                Example 1

                                const http = require('http-call')
                                await http.patch('https://google.com')

                              method post

                              static post: <T>(url: string, options?: HTTPRequestOptions) => Promise<HTTP<T>>;
                              • make an http POST request

                                Parameter url

                                url or path to call

                                Parameter options

                                Returns

                                {Promise}

                                Example 1

                                const http = require('http-call')
                                await http.post('https://google.com')

                              method put

                              static put: <T>(url: string, options?: HTTPRequestOptions) => Promise<HTTP<T>>;
                              • make an http PUT request

                                Parameter url

                                url or path to call

                                Parameter options

                                Returns

                                {Promise}

                                Example 1

                                const http = require('http-call')
                                await http.put('https://google.com')

                              method request

                              static request: <T>(
                              url: string,
                              options?: HTTPRequestOptions
                              ) => Promise<HTTP<T>>;

                                method stream

                                static stream: (
                                url: string,
                                options?: HTTPRequestOptions
                                ) => Promise<HTTP<unknown>>;
                                • make a streaming request

                                  Parameter url

                                  url or path to call

                                  Parameter options

                                  Returns

                                  {Promise}

                                  Example 1

                                  const http = require('http-call')
                                  let {response} = await http.get('https://google.com')
                                  response.on('data', console.log)

                                class HTTPError

                                class HTTPError extends Error {}

                                  constructor

                                  constructor(http: HTTP<any>);

                                    property body

                                    body: any;

                                      property http

                                      http: HTTP<any>;

                                        property statusCode

                                        statusCode: number;

                                          Type Aliases

                                          type FullHTTPRequestOptions

                                          type FullHTTPRequestOptions = http.ClientRequestArgs & {
                                          raw?: boolean;
                                          body?: any;
                                          partial?: boolean;
                                          headers: http.OutgoingHttpHeaders;
                                          };
                                          • {Object} HTTPRequestOptions {Object.<string, string>} headers - request headers {string} method - request method (GET/POST/etc) {(string)} body - request body. Sets content-type to application/json and stringifies when object {(boolean)} partial - do not make continuous requests while receiving a Next-Range header for GET requests {(number)} port - port to use

                                          type HTTPRequestOptions

                                          type HTTPRequestOptions = Partial<FullHTTPRequestOptions>;

                                            type Protocol

                                            type Protocol = 'https:' | 'http:';

                                              Package Files (1)

                                              Dependencies (6)

                                              Dev Dependencies (12)

                                              Peer Dependencies (0)

                                              No peer dependencies.

                                              Badge

                                              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/http-call.

                                              • Markdown
                                                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/http-call)
                                              • HTML
                                                <a href="https://www.jsdocs.io/package/http-call"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>