Purpose

Calls a URL and returns the payload of the HTTP response as a string.

Syntax

string HTTPGet();

returns the payload of the HTTP response as a string.

Example

This example pulls JSON from an example HTTP endpoint. The JSON is an array of objects, with an element named ‘title’.

function OnKeyPress(key)
{
    Log('Got keypress: ' + key);
    if (key == 'P') {
        Log("Getting items from API");
        var data = HTTPGet("http://jsonplaceholder.typicode.com/posts");
        items = JSON.parse(data);
        for (i in items) {
            Log(items[i].title);
        }
    }
}