Http service is extremely slow

Http service is extremely slow!

This is my code which is in a module:

local HttpService = game:GetService("HttpService")

local API_URL = "https://deluge-9nq7.onrender.com"

local function sendRequest(endpoint, method, data)
	local url = API_URL .. endpoint
	local headers = {
		["Content-Type"] = "application/json"
	}
	local requestBody = HttpService:JSONEncode(data)
	local response = HttpService:RequestAsync({
		Url = url,
		Method = method,
		Headers = headers,
		Body = requestBody
	})

	if response.Success then
		return HttpService:JSONDecode(response.Body)
	else
		error("Error communicating with API: " .. response.StatusCode .. " " .. response.StatusMessage)
	end
end

local RobloxAPI = {}

function RobloxAPI.addData(key, data)
	local endpoint = "/data/" .. key
	print(key, data)
	return sendRequest(endpoint, "POST", data)
end

function RobloxAPI.updateData(key, newData)
	local endpoint = "/data/" .. key
	return sendRequest(endpoint, "POST", newData)
end

function RobloxAPI.removeData(key)
	local endpoint = "/data/" .. key
	return sendRequest(endpoint, "DELETE", {})
end

function RobloxAPI.getData(key)
	local endpoint = "/data/" .. key
	return sendRequest(endpoint, "GET", {})
end

return RobloxAPI

Any time i make a post or delete request it takes almost a minute to show up.
Ive seen articles about this but they do not show the answer on how to fix this sluggish speed.

If you have any tips or adivice, it would be very appreciated!

You have to realise the delay between the ROBLOX server communicating with the API and then returning a result back.

2 Likes