Skip to content

The Web Standard Library

C272 edited this page Aug 30, 2019 · 2 revisions

Contains all web-related client and server functionality.


web.get(url)

Performs a GET request to the given URL. Returns an object, of the following format:

{
    status: 200 //http status code
    status_desc: "OK" //string, description of the status
    content: "..." //The returned content, as a string.
}

Parameters:

Name Description
url The URL to perform a GET request to.

Usage:

let x = web.get("http://example.com");
if (x.status == 200)
{
    print "Successful GET request!";
    print "Returned content - " + x.content + ".";
}

web.post(url, content)

Performs a POST request to the given URL, given an object to post. Returns an object, of the following format:

{
    status: 200 //http status code
    status_desc: "OK" //string, description of the status
    content: "..." //The returned content, as a string.
}

Parameters:

Name Description
url The URL to perform a GET request to.
content The object to POST, which is converted to JSON.

Usage:

let x = web.post("http://example.com", object {});