Building a 'friend' list
Hello, I hope there's a kind soul out there who can help me with this on a Friday evening!
I'm trying to build a kind of 'friend' list where a user presses a button and adds another user to their list. This means taking signup_ids from both users (the auth id from the user pressing the button) and adding both users to a new table:
I'm new to this, but I can sense that I'm close… At the moment I keep getting the error message from the precondition when I run and debug.
Could someone take a look and tell where I'm going wrong?
Thanks
Best Answer
-
Hello again @GavinReid,
The page that pops up for the Add-on asks from you to choose a value that will be used for the mapping of the add-on (meaning that each response of buddy_list should return the profile either of the user with .id or the other user - probably the friend - with the .signup_id.
Pick on and in the next step you will see the whole object.
Also keep in mind there is a custom way to do that as well (instead of the add-ons).
Using a for-each loop where as a list you pick the response of the "Query all records", and inside the loop you are making a get request for that specific item, and then appending it into a table.
It is surely more advanced, I am just throwing out some ideas so you can get the hang of Xano's possibilities.
Answers
-
Hi @GavinReid,
First and foremost, the answer of the query cannot be "False" (neither True of course) because it is not a boolean.
It is always an array. So in your case the precondition should check whether the array is empty (Probably what you need is == []).
I would also suggest another approach for the friendlist, in case you are new to this, where in the user's table you will create a field named friends in this way:Then in the new column you click Change Type
And you choose the Structure to be a list,
Then you append every new friend inside there.
My suggestion requires a little bit more complicated steps, but it is a much better approach, unless you are going to build a large production app.
Hit me up if you need anything else! -
Thanks a lot @Lefteris - blupry.com, that's exactly what I needed. I'll look into the list in the user table as well - thanks for the advice!
-
That now posts info to my friendlist table, but how can I get the info about friends to show up in my friendlist screen? I tried an add-on, but I can only get profile.signup_id (i.e. my own info). I want to display a list of my friends (with profile pic etc).
How can I add an add-on to get the profile info of signup2_id?
Thanks again!
-
That's great @Lefteris - blupry.com, thanks again for your help - I know this is probably very basic stuff, but it's still quite hard to get your head around!
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback