How to validate path variable/Uri parameter
Summary
How to validate path variable/Uri parameterContent
Hi ,
I have a Custom Api with method as GET , passing the parameter along with the url . Could you please suggest a method to check whether the parameter is null or not ?
Below given my code .
<span class="pln">service</span><span class="pun">.</span><span class="kwd">get</span><span class="pun">(</span><span class="str">'/mobile/custom/****/deviceVersion/:deviceType'</span><span class="pun">,</span><span class="kwd">function</span><span class="pun">(</span><span class="pln">req</span><span class="pun">,</span><span class="pln">res</span><span class="pun">){</span><span class="pln"><br/> </span><span class="kwd">var</span><span class="pln"> reqParams </span><span class="pun">=</span><span class="pln"> req</span><span class="pun">.</span><span class="pln">params</span><span class="pun">;</span><span class="pln"><br/> </span><span class="kwd">var</span><span class="pln"> finalResponse</span><span class="pun">;</span><span class="pln"><br/> </span><span class="kwd">var</span><span class="pln"> params</span><span class="pun">=</span><span class="str">'/'</span><span class="pun">+</span><span class="pln">reqParams</span><span class="pun">.</span><span class="pln">deviceType</span><span class="pun">;</span><span class="pln"><br/> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">reqParams</span><span class="pun">.</span><span class="pln">deviceType</span><span class="pun">==</span><span class="str">'{}'</span><span class="pun">){</span><span class="pln"> </span><span class="com">// ***Here is my problem***</span><span class="pln"><br/> finalResponse </span><span class="pun">=</span><span class="pln"> jbuilder</span><span class="pun">.</span><span class="pln">encode</span><span class="pun">(</span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln">json</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"><br/> json</span><span class="pun">.</span><span class="kwd">set</span><span class="pun">(</span><span class="str">'Response'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln">json</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"><br/> json</span><span class="pun">.</span><span class="kwd">set</span><span