Parse query parameter to number?
Answered
Bighead carp posted this in #help-forum
Bighead carpOP
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 @Bighead carp
10 Replies
Bighead carpOP
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 @Bighead carp
Answer
Bighead carpOP
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 🙂
Bighead carpOP
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
Bighead carpOP
@Bighead carp Click to see attachment
&752637460550385834 ?