This demo shows how to use webpack to build a bundle that includes the watson sdk and the user's action code into a single JavaScript file
The action code is located in ./index.js notice that a global.main = main
is added at the end, this allows webpack to expose the main function globaly that will be invoke by OpenWhisk.
install dependencies
npm intall
Build the bundle using webpack
npm start
Edit ./params.json and enter your credentials for the Watson Discovery API
{
"username":"",
"password":""
}
Deploy action with credentials set as default parameters
wsk action update myaction dist/bundle.js --param-file params.json
Run a query by invoking the action
wsk action invoke myaction -r