Why is this for i loop not finding anything in this table that is 17,000 things long

so im trying to make a script that can grab assets from the catalogue, but when i do a second for i=1 loop, it just finds nil. i printed out the table and it does have stuff inside of it, like alot of stuff.

also i have very little understanding of the http service so if you know why this doesnt work, please explain it so i can actually learn from this

script:

local event = game.ReplicatedStorage.Events.InsertModels
local marketplaceservice = game:GetService("MarketplaceService")

local insertservice = game:GetService("InsertService")
local assetservice = game:GetService("AssetService")

local Http = game:GetService("HttpService")

local AssetTypes = {
	["Hat"] = 9,
	["Shirt"] = 12,
	["Pants"] = 14
}

local url = "https://catalog.roproxy.com/v2/search/items/details?Subcategory="..AssetTypes["Hat"].."&SortType=0&SortAggregation=5&Limit=30"

local pages = 25

local assets = {}


event.OnServerEvent:Connect(function(player,idx)
	print("created")
	for i = 1, pages do
		local response = Http:GetAsync(url)..tostring(i)
		local data = Http:JSONEncode(Http:GetAsync(url))
		data = Http:JSONDecode(data)
		
		print(data)
		for ii = 1, #data do
			local asset = data[ii]
			print(asset)
			
			local name = asset.Name
			local id = asset.AssetId
			assets[#assets + 1] = "{Id = " ..id .. ", Name = \"" .. name .. "\"}"
			print(name)
		end
		print(i)
	end

	local source = "return { \n\t" .. table.concat(assets, ",\n\t") .. "\n}"
	print(source)
end)
1 Like