PricingBlog

Noob -Q: posting a new record to Xano

  • kookie_crisp985-1221607680502665307

    kookie_crisp

    1 year ago

    I am looking to create a new record in the Xano backend, however the record has multiple "variables" (I guess) that are not just text but also "enum" and the categories from the dropdown are a pain to copy...

    Is there a way that I can create a form, link the inputs to the API (POST) to generate the enum options as a list on the frontend(toddle)

    Or does this have to be 2 API requests? One for getting the options and another to POST the form for a new record?

    + the API needs user authentication

    P.S. this is like the 5th time I am recreating this whole little app because I get stuck somewhere for some reason and then cannot fix things and have to start from scratch...

    so any suggestions are welcome 🙂

    Cheers
  • andreasmoller-1221715524841635860

    Andreas Møller

    1 year ago

    I am not100% sure I understand your question. Do you want a select list on the frontend to be populated with options from your backend?
    In that case you can’t use the POST request because that has not been executed yet.
    You will need to fetch them separately
    💯1
  • kookie_crisp985-1221777382042767390

    kookie_crisp

    1 year ago

    Yes thank you. That actually answers the question.

    I am trying to be efficient with the number of APIs I call but I guess for this one, I need 2 requests...
    One to GET the lists and another to POST
  • andreasmoller-1221797987702018108

    Andreas Møller

    1 year ago

    👍
  • kookie_crisp985-1224355626415689798

    kookie_crisp

    1 year ago

    update on this one in case someone is also stuck, here is my progress:

    I managed to create a separate API that collects lists (enumeration options) for each of my columns ! I no longer have to create duplicate lists! Yay... (I had to use the Xano metadata API, which I then had to use an External API request within the GET API - and finally for the API response I set the results to an array. //I am sure there is a simpler way but now I have one API that lists every option and then I use individual select items to "filter" the one I need for THAT dropdown menu...

    What is a problem now is that sometimes it works and sometimes it does not...right now it does not work so you can see the "undefined" (select>option>"undefined"). I even made the darn thing Public to avoid the headache but still no-worky.

    What I did was convert the form into a container and that is when all hell broke loose. Now, I cannot go back...

    on the positive side, when it was working, I managed to get the nice drop-down options but when I wanted to assign them as variables, I could not... I saw somewhere also that there were similar questions so I thought I would share mine here as well. Maybe someone sees what I don't
    1224355625581023273-image.png
    1224355625941864539-image.png
    1224355626226814976-image.png