Why are you using code like this?
Can you share your settings when you call API? Are you using Bubble functions (Action or Get Data from API according to what you select in API Connector)?

Actually, I don’t see any reason to not use Bubble natives features…