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 or JSON or PUT or DELETE or HEAD
function( error, reply, status )