Back

HttpRequest

Hello World

HttpRequest sends a request to a server.

app.HttpRequest( type, baseUrl, path, params, callback, headers )

baseUrl and path will just be added to one string to get the address.
Multiple parameters are available using pipes:
    “param1=value1|param2=value2”

Example - Get Funfact

var address = "http://www.randomfunfacts.com";

app.HttpRequest( "GET", address, null, null, handleReply );

function handleReply( error, reply )
{
    if( error ) alert( reply );
    else
    {
        var funfact = reply.slice( reply.indexOf("<i>") + 3, reply.indexOf("</i>") );
        alert( funfact );
    }
}
    Copy     Copy All       Run      
string
string: url path
string: “GET” or “POST”
function( error, reply )