Functions to call remote websites or APIs
Sends a GET request to the given URL
Returns: nil
Parameters:
Name | Type | Default | Description |
---|---|---|---|
url | string | The URL to send the request to | |
onSuccess | function | A function to call when the request succeeds | |
onError | function | A function to call when the request fails | |
headers | table | A table of key-value pairs to send as headers | |
context | table | A value to pass to the onSuccess and onError functions |
WebRequest:Get("https://www.example.com/", onSuccess, onError, {["Accept"] = "application/json"}, context)
Sends a POST request to the given URL with the given data
Returns: nil
Parameters:
Name | Type | Default | Description |
---|---|---|---|
url | string | The URL to send the request to | |
postData | table | A table of key-value pairs to send as POST data | |
onSuccess | function | A function to call when the request succeeds | |
onError | function | A function to call when the request fails | |
headers | table | A table of key-value pairs to send as headers | |
context | table | A value to pass to the onSuccess and onError functions |
WebRequest:Post("https://www.example.com/", {["foo"] = "bar"}, onSuccess, onError, {["Accept"] = "application/json"}, context)