HttpService [ Unable to cast to dictionary ]


function Onx:FetchFromMedia(Http : string, Callback : () -> nil)
	--// [ Return Error If Http<String> Is Not Of Valid DataType ]
	assert(typeof(Http) ~= "string", `OnxClient Couldn't Fetch From Media`)
	local MediaDataFromResponse = HttpService:RequestAsync(Http)
end

RequestAsync takes a table with the values for the Url, Method, Headers and Body respectively, your just passing the http string

local MediaDataFromResponse = HttpService:RequestAsync({
	Url = Http,
	Method = "GET"
})

im going to assume your getting information so i left out the body and headers

To add to this, basically RequestAsync is a method of HttpService that allows you to highly configure an HttpRequest compared to other methods(because it allows you to set type, headers, etc.) but for simple requests such as GET and POST without custom headers in them you can just use the simplified methods named GetAsync and PostAsync. So as long you don’t plan to do any service authentication magic with custom headers and such you can just do:

local MediaDataFromResponse = HttpService:GetAsync(Http)
1 Like

Wow that’s some fancy lua coding with the type declarations and using assert.