get( url, header, successCB, [errorCB], [user], [password], [timeout], [certSource] ) method

Send a HTTP(S) GET request to a remote server.

Syntax

<static> get( url, header, successCB, [errorCB], [user], [password], [timeout], [certSource] ) → {anonymous.abort}

Parameters

Name Type Argument Description
url string   The http url with format http(s)://[user:password]@hostname[:port]/path.
header Object   HTTP header to be sent to server.This is an Object. Can be null.
successCB anonymous.sendRequestSuccessCB   Callback method upon success.
errorCB anonymous.sendRequestErrorCB (optional) Callback method upon failure.
user string (optional) User ID for basic authentication.
password string (optional) User password for basic authentication.
timeout number (optional) Timeout setting in seconds.
certSource Object (optional) Certificate description object.It can be one of HttpsConnection.CertificateFromFile, HttpsConnection.CertificateFromStore, or HttpsConnection.CertificateFromAfaria.

Returns

A JavaScript function object to cancel the operation.

Type:

anonymous.abort

Example

// To send a get request to server, call the method
HttpsConnection.get("http://www.google.com", null, function (data) {
           alert("Status: " + JSON.stringify(data.status));
           alert("Headers: " + JSON.stringify(data.headers));
         if (data.responseText){
                alert("Response: " + JSON.stringify(data.responseText));
         }
       }, 
     function (error) {
            alert("Failed: " + JSON.stringify(error));
     }};
// To send a get request to server with headers, call the method
HttpsConnection.get(url, {HeaderName : "Header value"}, successCB, errorCB);
// To send a get request to server with basic authentication, call the method
HttpsConnection.get(url, headers, successCB, errorCB, "username", "password");
// To send a get request to server with mutual authentication, call the method
HttpsConnection.get("https://hostname", headers, successCB, errorCB, null, null, 0, 
    new CertificateFromFile("/mnt/sdcard/my.p12", "password", "mykey"));

Source

Plugins/HttpsProxy/https-proxy.js, line 395.