Make 3 requests to a proxy Using httpservice How would I make it not have to wait for each other instead they send request at the same time

So the title explains it all, I’m basically sending 3 requests to a proxy, But of course the second request has to wait for the first request to finish and the third request has to wait for the second request.

Is there a way to get all over that instead send of waiting for each other requests they’d do it at the same time?
My Code: (All Httpservice requests to proxy are on another module but here is the script that gets their data)

	local GamepassData = AssetLoaderModule.GamepassesAPI(Player.UserId)
	local ShirtsData = AssetLoaderModule.ShirtsAPI(Player.Name)
	local TShirtsData = AssetLoaderModule.GetTShirts(Player.Name)

You can use threads, I guess. task.spawn() could help.

1 Like

Wrap the functions in a coroutine or task.spawn. If theres follow up code that immediately uses the variables then its best to just have it yield.

1 Like

I’m not efficient in threads but I think this could do something?

local function data(Player)
    local GamepassData
    local ShirtsData
    local TShirtsData

    task.spawn(function()
        GamepassData = AssetLoaderModule.GamepassesAPI(Player.UserId)
    end)

    task.spawn(function()
        ShirtsData = AssetLoaderModule.ShirtsAPI(Player.Name)
    end)

    task.spawn(function()
        TShirtsData = AssetLoaderModule.GetTShirts(Player.Mane)
    end)
end
1 Like

That works but you could add arguments inside task.spawn to make it look cleaner:

local GamepassData = task.spawn(AssetLoaderModule.GamepassesAPI, Player.UserId)
2 Likes

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