0 Outputs from API GET-request even though in Debug Mode I get Output

Options
Witti
Witti Member

Hey there!

I created an GET-Request for a table called "outfits" to output me different outputs filtered by parameters of the GET-request. Now when I Run it in debug mode, everything works fine and I get the correct outfits filtered by category. Here are the parameters for my Debug-Run:


But as soon as I Call the GET-request with parameters from "bubble, I get 0 results back even though the parameters are the same, as you see here:


I dont understand what im doing wrong and why I get 0 Output with these parameters.

If anybody could help me I would be very grateful! Thanks in advance for any replies!

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    This complicated input shape is an awkward fit for a get request. I recommend changing it to a POST so you can more easily handle the parameters.

    If you want to keep it as a get, you might look into accepting outfit-categories as a string, and then split that string in the function stack to get the array you want before continuing.

  • Witti
    Witti Member
    Options

    Hey @Ray Deck! Thanks for your reply!

    Sorry im kind of new to this, but I thought POST will create something on the database? The purpose of my request is to get all outfits back that fit the input parameters, so I dont understand how a Post would help me with that.

    I would be able change the categories input to as string as you suggested, but i have to clue on how to split that string in the function stack to get the array I want :/

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    GET and POST are just methods for making an HTTP request. By convention, we associate GET with asking for data and POST with writing it. But when the shape of the question is more complex, POST can be the right tool for the job. (This is why JSON-RPC, GraphQL and other more sophisticated systems all use POST for everything).

    Xano makes it easy to generate a GET for asking for data, but as you are experiencing, that's not always the right answer. Using "start from scratch" and building a new endpoint is a marvelous way to release the power of Xano. I discussed this approach in my appearance on Automate All The Things earlier this month.

    You don't have to move from GET to POST - there are multiple ways to get the filters you are looking for. I'd do a bit of experimentation to see what approach works for you from outside the run-and-debug context. Postman is a good tool for testing API endpoints this way.

    If you get deeper into your project and want a bit of help, we make progress on the hard end of projects on daily State Change Pro office hours.

  • Witti
    Witti Member
    Options

    Thank you @Ray Deck for your detailed explenation!

    Now I looked into splitting up the string I get and it worked fine so far as you can see here:

    And the variable I created (categoriesfinal) had the correct data as an array in it as you see here:

    But when I use the new variable now to filter my outfits, it only outputs the variable with the category of the first entry (in this case "Rave"). I dont get what im doing wrong here. Do you have an idea for me?

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    Could be an issue with how the variable is used in your query-all-records call. Could you screenshot or Loom that?

  • Witti
    Witti Member
    Options

    Its me once again @Ray Deck! I now know why it didnt work, there was a blank space before the second category...

    I can work with this from here on. Thank you very much for your help! You saved me :)

    I just have a more performance based question though. Now in order for my filters to work, i first have to create a new variable for all of my 4 array filters and throw out that blank spaces and split them in array for the new array. So the "Function Stack" of my API-Request is quite loaded, will this be very noticable in regards to the repsonse/performance time of the request?


  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    ON the perf front, this kind of preprocessing happens all the time, and the (tiny) compute shouldn't be noticable. Xano's debugger lets you monitor which processes take longer, and the request history shows which requests have a longer turnaround time. Initially don't worry about performance but watch the request history for slow turnaround. In those, look for the slow bit in the debugger. Focusing on just the bottlenecks dramatically increases the overall return on your perf engineering investment.

  • Witti
    Witti Member
    Options

    Thank you for that insight @Ray Deck. You really helped me alot!