PostAsync issues

Hello,

I am adding a feature in my User Check game which tells the user’s last online date. I tried to access the presence API that Roblox has, and I can’t seem to get it to work… Here’s the script:

local http = game:GetService("HttpService")
local jsonDecode = http.JSONDecode

local proxyUrl = "roproxy.com"
local baseUrl = "https://presence."..proxyUrl.."/v1/presence/last-online"

local function getUserOnlineStatus(userId)
	local data = {
		userIds = {
			userId
		}
	}
	local success, result = pcall(function()
		http:PostAsync(baseUrl,http:JSONEncode(data))
	end)
	if success then
		if result then
			print(result)
			local decodesuccess,decodedresult = pcall(jsonDecode,http,result)
			if decodesuccess then
				if decodedresult then
					return decodedresult
				else
					warn(decodedresult)
				end
				warn(decodedresult)
			end
		else
			warn(result) -- always warns 'nil'
		end
	else
		warn(result)
	end
end

Still wondering… I did a couple of print statements and all it returned was nil…

You never returned the http result inside your pcall

bro im honestly so stupid . . … .

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.