get

Http

Sends a GET request to the specified url.

$m.get("www.cloudpact.com", function(response){

   if(response.code === 200){

      $m.toast(response.result);

   } else{

      $m.toast(response.error.message);

   }

});

Syntax

        $m.get(url[, fp_callback])

        $m.get(url[, options, fp_callback])

Parameters

Url

string(required)

The url to which the request must be sent.

fp_callback

function (optional)

The function that is invoked after the request has been executed. The function receives the response object which contains the following properties,

  1. code - {Number}. 0 if the request failed to fire due to malformed url or network error, otherwise the http status code sent by the server.

  1. result - {Object}. The result contains the following properties,
  1. headers - {Object}. The response headers received from the server.
  2. data - {String}. The response data received from the server.

  1. error - {Object}. If code is 0, the error contains the properties,
  1. message - {String}. The error message.
  2. description - {String}. The error description in detail if any.

options

object (optional)  

Optional parameters object for the request. It can contain one or more of the following properties,

  1. headers - {Object}. The headers to be set for the request. Default value is {}.
  2. timeout - {Number}. The timeout of the request in milliseconds. If the response is not received from the server within timeout period, the request will be cancelled and timeout error will be thrown. Default value is 30000.