I'm seing a simple webhook throwing the following error:
node.js v8.9.4
TypeError: Cannot read property 'quantity' of undefined
at exports.webhook.functions.https.onRequest (/user_code/index.js:14:22)
at cloudFunction (/user_code/node_modules/firebase-functions/lib/providers/https.js:26:41)
at /var/tmp/worker/worker.js:671:7
at /var/tmp/worker/worker.js:655:9
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
request.body.result.parameters: { Quantity: 8, FoodType: [ 'Solid Food' ], FoodSource: [ 'Refrigerator' ], Units: 'Ounces' }
package.json
...
"dependencies": {
"firebase-admin": "~5.8.1",
"firebase-functions": "^0.8.1"
},
index.js:
const functions = require('firebase-functions');
// // Create and Deploy Your First Cloud Functions
//
exports.webhook = functions.https.onRequest((request, response) => {
console.log("request.body.result.parameters: ", request.body.result.parameters);
let params = request.body.result.paramters;
response.send({
speech:
`${params.Quantity} ${params.Units} of ${params.FoodType} from the ${params.FoodSource}`
});
});
I've seen similar reports, most of which referenced an issue with version 8, which should be resolved in version 8.1 of node
Tried:
Updated the dependency versions to older versions known to not have this issue
re-installed: npm install -g firebase-tools
Removed the 'Quantity' parameter then got the same error related to 'Units' parameter