It is also what comes through when I print and unpack it.
Server:
local HttpService = game:GetService("HttpService")
local url = "[REDACTED]"
local response = HttpService:GetAsync(url)
local data = HttpService:JSONDecode(response)
local book = {}
for i,v in pairs(data) do
table.insert(book, response)
end
for i,v in pairs(book) do
print(unpack(book))
end
What I want to do is fetch a player’s booking and grab elements like table number (I assume it would be for i,v in pairs (book) do v[1] or something like that)
Aplogies if this doesn’t make any sense, I am confused as well.
So can you be more specific? Is it erroring, or what’s happening? Is the server sending a valid JSON response? I’m quite confused on what you’re doing here, more because you have data just being copied into another array using a for loop. – And I think I see your mistake reading now.
Change
for i,v in pairs(data) do
table.insert(book, response)
end
to
for i,v in pairs(data) do
table.insert(book, v)
end
OR
Just change the book variable to
local book = data; -- it's the same thing
So what went wrong?
You are totally skipping over the JSON here, you were adding the response as an array, when you should have been using the JSON response for the array.
Edit: I kept the stuff where I was sharing my thought process, so that’s where the – Oh I think I see the issue now came from.
local HttpService = game:GetService("HttpService")
local url = "[REDACTED]"
local response = HttpService:GetAsync(url)
local data = HttpService:JSONDecode(response)
local book = date;
for i,v in pairs(book) do
print(i,v)
end
local response = HttpService:GetAsync(url)
local data = HttpService:JSONDecode(response)
local book = data;
for i,v in pairs(data) do
table.insert(book, v)
end
for i,v in pairs(book) do
print(i,v)
end
Sorry for breaking the news, I know that feeling of having to re-do everything. I got started with web-development in PHP, lots of work. And for the Roblox issue, if you go to the site and manually perform the request you’re trying to do on Roblox what does it say?