Back

HttpRequest

JS Py
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 );
    }
}
from native import app

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

app.HttpRequest("GET", address, None, None, handleReply)

def handleReply(error, reply):
    if error:
        app.Alert(reply)
    else:
        funfact = reply[reply.index("<i>") + 3: reply.index("</i>")]
        app.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 )