Make an API to allow a user to update their name
Options
I have a database of Users that I use for authentication. I have a field in the user table called 'name'. This feels super basic but I can't figure out how to format an API that allows a logged in authenticated user to update their name in the table.
End result:
Allows user to update their name field on POST
Doesn't update the whole record, just the name field
Any ideas or links to guides would be massively appreciated!
Thanks
End result:
Allows user to update their name field on POST
Doesn't update the whole record, just the name field
Any ideas or links to guides would be massively appreciated!
Thanks
Comments
-
Could you just use a POST endpoint, only take the ID and name inputs, then only update the name field? I don't think you'd even need the ID input and use the Auth ID instead.
[CleanShot 2021-11-22 at 08.34.27@2x.jpg] -
What said, I'd probably make an endpoint just for updating the name only if that's what is exposed in your front-end. Nothing wrong with having an endpoint dedicated to a specific action. You could also check out the conditional set filters if you want a catch all (most) edit endpoint
-
Thanks Karl!
-
Thanks Michael
-
Hi Karl, finally got back to this - very close to working but getting an issue when I add the endpoint in Draftbit.
All works in Xano:
[Screenshot 2021-12-04 at 16.31.11.png]
In Draftbit I get this error:
[Screenshot 2021-12-04 at 16.32.37.png]
Setup is below:
[Screenshot 2021-12-04 at 16.32.22.png][Screenshot 2021-12-04 at 16.32.11.png][Screenshot 2021-12-04 at 16.32.16.png]
Any ideas? -
In DB step 2 you have {user_id} in the base URL but that needs to be a DB variable like {{user_id}}. Double brackets not single.
Then you can delete the user_id from the Xano input because that’ll be pulled from the authenticated user via the URL variable. -
Legend thanks, one step closer to it working!
I have made the changes suggested above and I can now save the endpoint and it works on test. 🎉
However, when I try to hook a button to the endpoint it is asking for the user_ID (rather than getting it from the Auth):
[Screenshot 2021-12-04 at 17.02.52.png] -
Can you pull the user_id from a Fetch it’s already nested under? Or make a new endpoint that gets the auth user’s info? -
Great idea, all working now, thanks!
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