JSON and HTTP Communication
Overview
How to Use
Function
Description
Receiving a response from the URL
-- Imports HttpService
local HttpService = game:GetService("HttpService")
local baseUrl = "Enter the HTTP URL here"
local success, errorMessageOrResult, response = nil, nil, nil
local function HttpGet()
-- Handles exceptions with pcall() as asynchronous requests can fail or encounter errors
success, errorMessageOrResult = pcall(function()
-- Sends an HTTP GET request to the "baseUrl" address and stores the response in the "response" variable
response = HttpService:GetAsync(baseUrl)
end)
local messageSuccess = string.format("success: %s", success)
local messageErrorOrResult = string.format("errorMessageOrResult: %s", errorMessageOrResult)
local messageResponse = string.format("response: %s", response)
print("messageSuccess: ", messageSuccess)
print("messageErrorOrResult: ", messageErrorOrResult)
print("messageResponse: ", messageResponse)
endSending JSON Data to the URL to Receive a Response
Using JSON Data Received from the URL
Note
Last updated