Update example (#445)
* Changes:
- Update nodejs client examples
- Update invoke action commands to use common flags for all examples
Co-authored-by: Yadwinder <yadwinder.singh@ibm.com>
diff --git a/_includes/code/hello.js b/_includes/code/hello.js
index 685fd4e..3653f77 100644
--- a/_includes/code/hello.js
+++ b/_includes/code/hello.js
@@ -1,3 +1,4 @@
-function main() {
- return {payload: 'Hello world'};
-}
+function main(args) {
+ const name = args && args.name || "stranger";
+ return { greeting: `Hello ${name}!` };
+}
\ No newline at end of file
diff --git a/_includes/code/manifest-for-helloJS-2.yaml b/_includes/code/manifest-for-helloJS-2.yaml
index a1e0bc0..64d7d1e 100644
--- a/_includes/code/manifest-for-helloJS-2.yaml
+++ b/_includes/code/manifest-for-helloJS-2.yaml
@@ -3,8 +3,9 @@
actions:
helloJS:
code: |
- function main() {
- return {payload: 'Hello world'};
+ function main(args) {
+ const name = args && args.name || "stranger";
+ return { greeting: `Hello ${name}!` };
}
runtime: nodejs:10
diff --git a/_layouts/documentation.html b/_layouts/documentation.html
index e17dc07..f71d369 100644
--- a/_layouts/documentation.html
+++ b/_layouts/documentation.html
@@ -872,18 +872,14 @@
</div>
</li>
<li style="list-style-type: decimal">
- Invoke the <i>helloJS</i> action as a blocking activation:
+ Invoke an action <i>helloJS</i>:
<div class="terminal">
-{% highlight bash %}$ wsk action invoke helloJS --blocking{% endhighlight %}
+{% highlight bash %}$ wsk action invoke helloJS --result --param name World{% endhighlight %}
</div>
<div class="terminal">
{% highlight yaml %}
{
-"result": {
-"payload": "Hello world"
-},
-"status": "success",
-"success": true
+ "greeting": "Hello World!"
}{% endhighlight %}
</div>
</li>
@@ -988,7 +984,7 @@
<li style="list-style-type: decimal">
Invoke an action <i>helloGo</i>:
<div class="terminal">
-{% highlight bash %}$ wsk action invoke helloGo -r -p name gopher{% endhighlight %}
+{% highlight bash %}$ wsk action invoke helloGo --result --param name gopher{% endhighlight %}
</div>
<div class="terminal">
{% highlight yaml %}
@@ -1087,7 +1083,7 @@
</li>
<li style="list-style-type: decimal">Invoke the <i>helloPy</i> action using command-line parameters:
<div class="terminal">
-{% highlight bash %}$ wsk action invoke helloPy --blocking --param name World{% endhighlight %}
+{% highlight bash %}$ wsk action invoke helloPy --result --param name World{% endhighlight %}
</div>
<div class="terminal">
{% highlight yaml %}
@@ -1212,7 +1208,7 @@
<li style="list-style-type: decimal">
Invoke an action <i>helloJava</i>:
<div class="terminal">
-{% highlight bash %}$ wsk action invoke helloJava --blocking --result{% endhighlight %}
+{% highlight bash %}$ wsk action invoke helloJava --result{% endhighlight %}
</div>
<div class="terminal">
{% highlight yaml %}
@@ -1290,7 +1286,7 @@
<li style="list-style-type: decimal">
Invoke an action <i>helloPHP</i>:
<div class="terminal">
-{% highlight bash %}$ wsk action invoke helloPHP --blocking --result --param name World{% endhighlight %}
+{% highlight bash %}$ wsk action invoke helloPHP --result --param name World{% endhighlight %}
</div>
<div class="terminal">
{% highlight yaml %}
@@ -1396,7 +1392,7 @@
<li style="list-style-type: decimal">
Invoke an action <i>hello_ruby</i>:
<div class="terminal">
-{% highlight bash %}$ wsk action invoke hello_ruby --blocking --result --param name World{% endhighlight %}
+{% highlight bash %}$ wsk action invoke hello_ruby --result --param name World{% endhighlight %}
</div>
<div class="terminal">
{% highlight yaml %}
@@ -1493,7 +1489,7 @@
<li style="list-style-type: decimal">
Invoke an action <i>helloSwift</i>:
<div class="terminal">
-{% highlight bash %}$ wsk action invoke helloSwift -r -p name Carlos{% endhighlight %}
+{% highlight bash %}$ wsk action invoke helloSwift --result --param name Carlos{% endhighlight %}
</div>
<div class="terminal">
{% highlight yaml %}
@@ -1638,7 +1634,7 @@
Invoke an action <i>helloDotNet</i>:
<div class="terminal">
{% highlight bash %}
-$ wsk action invoke helloDotNet -r -p name Shawn
+$ wsk action invoke helloDotNet --result --param name Shawn
{% endhighlight %}
</div>
<div class="terminal">