Register today for Oracle CloudWorld. October 17th - 20th, Las Vegas

Register now

Hillel Cooperman, Senior VP of User Experience Design, has a message for you on Oracle CloudWorld

Watch now
How to validate path variable/Uri parameter — Cloud Customer Connect
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

How to validate path variable/Uri parameter

Received Response
16
Views
8
Comments
edited Feb 17, 2017 8:00AM in Digital Assistant and Mobile 8 comments

Summary

How to validate path variable/Uri parameter

Content

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

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!