Sintaks
HttpGet(context: DataModel, url: string, cache?: boolean | number): stringArgumen
| Nama | Tipe | Deskripsi |
|---|---|---|
context | DataModel | Method-call self value. Use game:HttpGet(url, cache) or game:HttpGetAsync(url, cache). |
url | string | URL string to request. |
cache? | boolean | number | Optional cache control. true or numeric 1 enables the URL cache. |
Return
| Nama | Tipe | Deskripsi |
|---|---|---|
body | string | Downloaded response body string, cached body string, or an empty string when the request cannot be opened. |
Deskripsi
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.
Panggil dengan 3 parameter: context, url, cache. Tabel argumen menjelaskan nilai wajib dan nilai yang hanya menyempurnakan perilaku.
Mengembalikan body (string). Gunakan tabel returns untuk memisahkan nilai sukses, hasil nil, dan error yang bisa dipulihkan.
Contoh
Run a DataModel-style GET request and return the response body string.
local body = game:HttpGet("https://example.com", true)
print(body)