Utilities

HttpGet

Performs a GET request for game:HttpGet(url, cache) or game:HttpGetAsync(url, cache) and returns the response body string.

Syntax

HttpGet(context: DataModel, url: string, cache?: boolean | number): string

Arguments

NameTypeDescription
contextDataModelMethod-call self value. Use game:HttpGet(url, cache) or game:HttpGetAsync(url, cache) so the DataModel is passed as argument 1.
urlstringURL string passed to DownloadUrl after the blacklist check.
cache?boolean | numberOptional cache control. boolean true enables urlCache; numeric 1 also enables it. Missing, nil, false, and other numbers leave cache disabled.

Returns

NameTypeDescription
bodystringDownloaded response body, cached body, or an empty string when the request cannot be opened.

Description

Performs a GET request for game:HttpGet(url, cache) or game:HttpGetAsync(url, cache) and returns the response body string. The URL must pass Real's URL restrictions.

Call it with 3 parameter(s): context, url, cache. The argument table explains which values are required and which ones only refine the behavior.

It returns body (string). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Run a DataModel-style GET request and return the response body string.

local body = game:HttpGet("https://example.com", true)
print(body)