Last active
April 9, 2020 20:34
-
-
Save upkarlidder/897f6c3e3ce313736cdbacde9acdb17a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# | |
# main() will be run when you invoke this action | |
# | |
# @param Cloud Functions actions accept a single parameter, which must be a JSON object. | |
# | |
# @return The output of this action, which must be a JSON object. | |
# | |
# | |
import sys | |
def main(dict): | |
if 'name' in dict: | |
return { 'message': 'Hello ' + dict['name'] } | |
else: | |
return { 'message': 'Hello world' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main(params) { | |
return new Promise((resolve, reject) => { | |
// long running operation | |
console.log('params start'); | |
console.log(params); | |
console.log('params end'); | |
if (params && params.name) { | |
console.log(`hello ${params.name}`); | |
resolve({ msg: `hello ${params.name}` }); | |
} else { | |
console.log('hello world'); | |
reject({ msg: 'hello world' }); | |
} | |
}) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main(params) { | |
if(params && params.name) { | |
console.log(`hello ${params.name}`); | |
return {msg: `hello ${params.name}`}; | |
} else { | |
console.log('hello world'); | |
return {msg: 'hello world'}; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Commands
ibmcloud fn action create helloworldcfe index.js
ibmcloud fn action invoke helloworldcfe
ibmcloud fn activation get {activation id from 2}
Promise version