Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST Service - URI formation for unique check

I've got a signup HTML form with a username field that I want to check against registered usernames to ensure uniqueness. I considered making a GET request to api/users/:username, if it returns 200 consider taken, if 404 consider available.

Is this overkill for what I'm trying to do since I would be returning the actual user at every request (which happens when the input field changes)? If so what alternatives would you guys suggest.

like image 578
ghjunior Avatar asked Dec 11 '25 10:12

ghjunior


1 Answers

Make a HEAD request and just get the headers.

like image 68
Mark Lutton Avatar answered Dec 14 '25 09:12

Mark Lutton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!