Catalog API returns empty table?

  1. What do you want to achieve? Keep it simple and clear!
    Im trying to make a catalog type of game for a guy im working for.

  2. What is the issue? Include screenshots / videos if possible!

The problem is that. When i try to call? the api. It returns a json table with different accessories. But when you try to decode it. It deosnt work. Its empty all of a sudden?

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have been looking through the dev forum for almost 2 days now. But cant seem to find anything helpful

Either its broken somehow. Or im just doing something wrong?

Heres my code atm:

local SERVICE = game:GetService("HttpService")
local URL = "https://catalog.rprxy.xyz/v1/search/items/details?Category=11&MaxPrice=10000"
local GET = SERVICE:GetAsync(URL)
local DECODE = SERVICE:JSONDecode(GET)

print(GET)
print(#DECODE)

Hi there, the problem is you did #DECODE which means it tried to get the length

local SERVICE = game:GetService("HttpService")
local URL = "https://catalog.rprxy.xyz/v1/search/items/details?Category=11&MaxPrice=10000"
local GET = SERVICE:GetAsync(URL)
local DECODE = SERVICE:JSONDecode(GET)

print(GET)
print(DECODE)

print(DECODE.data[1].name)
1 Like

Ye i know. I did that totry to debug when it wasnt working.

I also already tried “DECODE.data[1]”. But it still didnt work?

Works for me.

1 Like

I still get this?

Also sorry for the slow response. I took a small nap :sweat_smile:

Have you tried just printing DECODE?

1 Like

Yes. But that just printed out the table which you cant read

Unpack only works on arrays that’s why it isn’t working for you, you can easily just index what you’re looking for so

 DECODE.data[1].name
 DECODE.data[1].price

by doing

print(DECODE.data[1]) 

you should be able to read it.
And if you want to go to a different accessory you just change the [1] => [2] => [3] so forth.

1 Like