Options
All
  • Public
  • Public/Protected
  • All
Menu

HTTP

The HTTP and HTTPResponse objects are used to run synchronous HTTP requests to communicate with APIs, or just read pages from the web. A full set of custom settings can be passed, and all HTTP methods (GET, POST, PUT, DELETE, etc.) are supported.

Example

var http = HTTP.create(); // create HTTP object

var response = http.request({
  "url": "http://myurl.com/api",
  "method": "POST",
  "data": {
    "key":"value"
  },
  "headers": {
    "HeaderName": "HeaderValue"
  }
});

if (response.success) {
  var text = response.responseText;
  var data = response.responseData;
}
else {
  console.log(response.statusCode);
  console.log(response.error);
}

Hierarchy

  • HTTP

Index

Methods

Methods

request

  • Parameters

    • settings: object

      An object configuring the request.

      • Optional data?: object

        An object containing data to be encoded into the HTTP body of the request.

        • [x: string]: string
      • Optional encoding?: "json" | "form"

        Format to encode data in the body of request.

      • Optional headers?: object

        An object contain key-values to be added as custom headers in the request.

        • [x: string]: string
      • method: string

        The HTTP method, like "GET", "POST", etc.

      • Optional parameters?: object

        Query parameters to merge with the url. Query parameters can also be part of the original url value.

        • [x: string]: string
      • Optional password?: string

        A password to encode for Basic Authentication.

      • url: string

        The absolute HTTP URL for the request.

      • Optional username?: string

        A username to encode for Basic Authentication.

    Returns HTTPResponse

Static create

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc