Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Net

Index

Methods

Static ajax

  • Creates an Ajax request. Returns an object that can be used to chain calls. For example:

     $t.post("/post-test")
       .data({ key: "value" })
       .end(function(res) {
         assert.equal("value", res.responseText);
       });
    
     $t.get("/get-test")
       .set("Accept", "text/html")
       .end(function(res) {
         assert.equal("Sample text", res.responseText);
       });

    The available chained methods are:

    set -- set a HTTP header data -- the postBody end -- send the request over the network, and calls your callback with a res object send -- sends the request and calls data: .send({ data: value }, function(res) { });

    Parameters

    Returns AjaxRequest

    A chainable object for further configuration

Static get

  • An Ajax GET request.

     $t.get("/get-test")
       .set("Accept", "text/html")
       .end(function(res) {
         assert.equal("Sample text", res.responseText);
       });

    Parameters

    • url: string

      The URL to request

    • Optional options: AjaxRequestOptions

      The Ajax request options

    Returns AjaxRequest

    A chainable object for further configuration

Static jsonp

  • A jsonp request. Example:

    var url = "http://feeds.delicious.com/v1/json/";
    url += "alex_young/javascript?callback={callback}";
    
    connectsdk.net.jsonp(url, {
      success: function(json) {
        console.log(json);
      }
    });

    Parameters

    Returns void

Static parseJSON

  • parseJSON(string: string): unknown
  • Parses JSON represented as a string.

    Parameters

    • string: string

      The original string

    Returns unknown

    A JavaScript object

Static parseXML

  • parseXML(text: string): unknown
  • Parses XML represented as a string.

    Parameters

    • text: string

    Returns unknown

    A JavaScript object

Static post

  • An Ajax POST request.

     $t.post("/post-test")
       .data({ key: "value" })
       .end(function(res) {
         assert.equal("value", res.responseText);
       });

    Parameters

    • url: string

      The URL to request

    • Optional options: AjaxRequestOptions

      The Ajax request options (postBody may come in handy here)

    Returns AjaxRequest

    An object for further chaining with promises

Static serialize

  • serialize(object: object | string): string
  • Serialize JavaScript for HTTP requests.

    Parameters

    • object: object | string

      An Array or Object

    Returns string

    A string suitable for a GET or POST request