SIGN UP

Net

Methods

httpRequest(url: String, callback: Function, options: Net.HttpRequestOptions): void

Performs a regular HTTP request. GET is the default request method. See VoxEngine Reference for the limits. TCP connect timeout is 6 seconds and total request timeout is 90 seconds.

Parameters

  • url:

    String

    HTTP url to query

  • callback:

    Function
    Optional

    Function to be called on completion. The function receives a response object of type Net.HttpRequestResult as a first argument

  • options:

    Net.HttpRequestOptions
    Optional

    Advanced settings

Returns

  • Return:

    void

Examples

request:

 Net.httpRequest("https://voximplant.com/", function(e) {
      if(e.code == 200) { 
        Logger.write("Connected successfully");
        Logger.write("code:  " + e.code);
        Logger.write("data:  " + e.data);
        Logger.write("error:  " + e.error);
        Logger.write("headers:  " + JSON.stringify(e.headers));
        Logger.write("raw_headers:  " + e.raw_headers);
        Logger.write("text:  " + e.text);
      } else { 
        Logger.write("Unable to connect");
      }
    },  { rawOutput: true } );
httpRequestAsync(url: String, options: Net.HttpRequestOptions): Promise

Performs an asynchronous HTTP request, i.e., the method returns a Promise which resolves with a HttpRequestResult object. GET is the default request method. See VoxEngine Reference for the limits. TCP connect timeout is 6 seconds and total request timeout is 90 seconds.

Parameters

  • url:

    String

    HTTP url to query

  • options:

    Net.HttpRequestOptions
    Optional

    Advanced settings

Returns

  • Return:

    Promise

Examples

request:

 Net.httpRequestAsync('https://voximplant.com/').then(function() { Logger.write("request complete"); });
sendMail(mailServerAddress: String, from: String, to: String|Array, title: String, body: String, callback: Function, options: Net.SendMailOptions): void

Send e-mail using specified e-mail server.

Parameters

  • mailServerAddress:

    String

    Address of mail server to use

  • from:

    String

    From address of e-mail message

  • to:

    String|Array

    To address or list of those

  • title:

    String

    Message title

  • body:

    String

    Message body

  • callback:

    Function

    Function to be called on completion

  • options:

    Net.SendMailOptions

    Advanced settings

Returns

  • Return:

    void

Examples

request:

Usage example

 Net.sendMail("smtp.server.com",
                 "from@server.com",
                 "to@server.com",
                 "Title of the letter",
                 "Body of the letter",
                 function stub(){},
                 {login: "login_from@server.com", password:"password_from@server.com"});
sendMailAsync(mailServerAddress: String, from: String, to: String|Array, title: String, body: String, options: Net.SendMailOptions): Promise

Send e-mail using specified e-mail server

Parameters

  • mailServerAddress:

    String

    Address of mail server to use

  • from:

    String

    From address of e-mail message

  • to:

    String|Array

    To address or list of those

  • title:

    String

    Message title

  • body:

    String

    Message body

  • options:

    Net.SendMailOptions

    Advanced settings

Returns

  • Return:

    Promise

Examples

request:

See how to fill in the parameters

 Net.sendMail("smtp.server.com",
                 "from@server.com",
                 "to@server.com",
                 "Title of the letter",
                 "Body of the letter",
                 {login: "login_from@server.com", password:"password_from@server.com"});