please forgive me, totally new @ lambda , node.
i trying replicate this git order pizza using aws iot button.
my current code is:
var pizzapi = require('dominos'); var mystore = new pizzapi.store( { id: 'example' } ); var myaddress = new pizzapi.address( { street: 'example', city: 'example', region: 'example', postalcode: 'example' } ); var mycustomer = new pizzapi.customer( { firstname: 'example', lastname: 'example', address: myaddress, phone: 'example', email: 'example@gmail.com' } ); var order = new pizzapi.order( { customer: mycustomer, storeid: mystore.id } ); var cardnumber='example'; var cardinfo = new order.paymentobject(); cardinfo.amount = order.amounts.customer; cardinfo.number = cardnumber; cardinfo.cardtype = order.validatecc(cardnumber); cardinfo.expiration = 'example'; cardinfo.securitycode = 'example'; cardinfo.postalcode = 'example'; order.payments.push(cardinfo); function orderdominos(event, context) { var clicktype = event.clicktype; switch(clicktype.tolowercase()) { case "single": { order.additem( new pizzapi.item( { code: 'p_14screen', options: {}, quantity: 1 } ) ); break; } case "double": { order.additem( new pizzapi.item( { code: 'p_14screen', options: {}, quantity: 1 } ) ); break; } case "long": { order.additem( new pizzapi.item( { code: 'p_14screen', options: {}, quantity: 1 } ) ); break; } } order.validate( function(result) { console.log("order validated"); } ); order.price( function(result) { console.log("order priced"); } ); order.place( function(result) { console.log("price is", result.result.order.amounts, "\nestimated wait time",result.result.order.estimatedwaitminutes, "minutes"); console.log("order placed!"); context.succeed(event); } ); } exports.handler = orderdominos;
the file structure is:
- orderdominos.js
- node_modules/dominos
i zipped files, uploaded lambda, , pointed header "index.handler"
what doing wrong?
edit: error
unable import module 'orderdominos': error @ function.module._resolvefilename (module.js:325:15) @ function.module._load (module.js:276:25) @ module.require (module.js:353:17) @ require (internal/module.js:12:17) @ object.<anonymous> (/var/task/node_modules/dominos/src/http-json.js:1:74) @ module._compile (module.js:409:26) @ object.module._extensions..js (module.js:416:10) @ module.load (module.js:343:32) @ function.module._load (module.js:300:12) @ module.require (module.js:353:17)
in case, mentioned handler
index.handler
root filename app.js
. changing index.js
worked.
also make sure zip file has index.js, node_modules , package.json
directly.
should be:
zip file --> index.js package.json node_modules
not
zip file --> some_folder_name --> index.js package.json node_modules
Comments
Post a Comment