Parse query parameter to number?
Answered
Southern rough shrimp posted this in #help-forum
Southern rough shrimpOP
Is there a way of only accepting query params of type number? i.e removing the manual parsing from string to integer?
Answered by B33fb0n3
you can try catch the number. If it's not an number throw an error @Southern rough shrimp
10 Replies
Southern rough shrimpOP
in an ideal world, I could define the params as such (removing use of Number.parseInt
you can try catch the number. If it's not an number throw an error @Southern rough shrimp
Answer
Southern rough shrimpOP
Yea but my idea is to not have to do that
cleaner code
of course it would be a more cleaner code, but you also want to check the params. And the url is a string. In every case. So handle it as a string or try catch the number 🙂
Southern rough shrimpOP
I may just change the id to string in the database so none of this number stuff is required
thanks for the help
yea... please mark solution
Southern rough shrimpOP
@Southern rough shrimp Click to see attachment
&752637460550385834 ?