Miscellaneous

HttpGet

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

ไวยากรณ์

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

Arguments

ชื่อชนิดคำอธิบาย
contextDataModelMethod-call self value. Use game:HttpGet(url, cache) or game:HttpGetAsync(url, cache).
urlstringURL string to request.
cache?boolean | numberOptional cache control. true or numeric 1 enables the URL cache.

Returns

ชื่อชนิดคำอธิบาย
bodystringDownloaded response body string, cached body string, or an empty string when the request cannot be opened.

คำอธิบาย

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.

เรียกด้วย parameter 3 ค่า: context, url, cache ตาราง arguments อธิบายค่าที่จำเป็นและค่าที่ปรับพฤติกรรม

ส่งคืน body (string) ใช้ตาราง returns เพื่อแยกค่าที่สำเร็จ ผลลัพธ์ nil และ error ที่จัดการต่อได้

ตัวอย่าง

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

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