Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Module API Http help? [Closed]

Im trying to get my 'module' to load into the server using Pastebin as a database. But, I don't get any errors, but I cannot yet get the 'module' ranks to insert into Ranks table.

Help?

Database : http://pastebin.com/EiFyEHzr

Any help would be nice :)

My output from print(#Ranks) = 0

local Ranks = {}
local url = "http://pastebin.com/raw/EiFyEHzr" -- (raw data)
local http = game:GetService("HttpService")

function update()
	print(Ranks)
	local html = loadstring( http:GetAsync(url, true) )()
	if type(html) == "string" then
		local json = http:JSONDecode(html)
		if type(json) == "table" then
			for index = 1,#Ranks do
				table.remove(Ranks, index)
			end
			for _,v in next,json do
				print(v.User, v.Details)
				table.insert(Ranks, v)
			end
		else
			print("Not a table!")
		end
	end
end

update()
print(#Ranks)
table.foreach(Ranks, print)

1 answer

✓ Accepted answer

You're returning a table

I'd advise keeping pure JSON in the paste instead of Lua code, as it introduces fewer vulnerabilities.

1 comment

0

Ah, Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.