How do I handle optional query parameter?

  • fantastic_seahorse_35860_63547-1259669930178121860

    Dan

    8 months ago

    I have a button that populates a query parameter only on click. I have a variable with default value null that gets specific value "A" when the button is clicked which will be used as a query parameter in the API request.

    How do I make this query parameter optional so that when the button is not clicked this parameter is omitted in the request URL?
  • erikbeus-1259775529054371850

    Erik Beuschau

    8 months ago

    Optional query parameters in API requests are coming with the new version of APIs (that we're currently working on).
    For now, you will need to have 2 different API requests and call the relevant one depending on the state of your application.
    πŸ‘2
  • frankenwompus-1281013505587413075

    Fisher

    6 months ago

    @Erik Beuschau Do you have a timeline for the new version of APIs? Additionally, how would you suggest going about putting together a marketplace-type search? An example would be an auto marketplace, where the price, make, model, year, mileage etc are all optional in the API query? Are you saying we'd need 10's of different API calls depending on what's been selected/filtered by the user?
  • erikbeus-1281155667259949068

    Erik Beuschau

    6 months ago

    Timelines often change πŸ˜‰ But we are testing internally atm, and hope to start testing with heroes in a week or two. Depending on feedback, we will roll them out for everyone shortly after 🀞
    If you have a lot of different (optional) filters, I think the better option for now is to not use query parameters in the API dialog, and just embed them directly in the url using a formula. In that formula, you can handle the optional logic and only include the filters needed
    πŸ‘1
  • frankenwompus-1281218368614957138

    Fisher

    6 months ago

    Thanks, Erik. That's totally understandable on timelines!
    I watched a couple videos (one of yours, I think!) on adding querys to a url with formulas, but I'm not sure how to get that to actually filter the info on the page. Does the API grab all records and then the url query filters it down? Or does the url query somehow get passed to the API?
  • erikbeus-1281219619083911219

    Erik Beuschau

    6 months ago

    Query parameters are sent with an https request to your server/back-end that will need to use the passed information to filter the results for the client.
  • frankenwompus-1281233583096467467

    Fisher

    6 months ago

    I think I'm understanding now, thanks. I'll need to brush up on formulas, but I appreciate the direction/suggestion!
    πŸ™Œ1
  • frankenwompus-1281259223908614256

    Fisher

    6 months ago

    I've got it working now, thank you again! For posterity, my issue was that I was still trying to construct the formula within the Query and Path formulas (red arrows), instead of building the whole thing in the API URL formula (green arrow).
    1281259223698640997-image.png
    πŸ”₯1

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code β€” but accessible to your entire team!

Try toddle β€” it's free!

Β© Copyright 2024 toddle. All rights reserved.