Hello. The problem I'm facing could be something very novice, or something I have overlooked. I need help in solving this. I have an API written in Lambda (serverless), however, when I am trying to update(for which I'm using dynamoose), I do not seem to return any response, as the control seem to be going out of context and responding with nothing.Here is my entire function.module.exports.update = async (event, context) => { const req = event.body; const uuid = (event.pathParameters) ? event.pathParameters.id : event.path.id const primaryImage = await Image.upload(req) await Foodie.update({ uid: uuid }, { name: req.name, primaryImage: primaryImage, secondaryImage:req.secondaryImage, pois: req.pois, description: req.description, ingredients: req.ingredients, coreMLIdentifier: req.coreMLIdentifier, updatedAt: moment().format() }, { condition: 'attribute_exists(uid)' }, (err, foodie) => { if (err && err.code == 'ConditionalCheckFailedException') { const error = { status: { 'code': 404, 'errorDetail': 'record not found', 'message': 'NOT FOUND' } }; return error; } var success = { data: { result: foodie }, status: { 'code': 200, 'errorDetail': '', 'message': 'OK' } }; return success; }); # After the execution the control is going here. }; I also tried doing something like thismodule.exports.update = async (event, context) => { const req = event.body; const uuid = (event.pathParameters) ? event.pathParameters.id : event.path.id const primaryImage = await Image.upload(req) var response = await Foodie.update({ uid: uuid }, { name: req.name, primaryImage: primaryImage, secondaryImage: req.secondaryImage, pois: req.pois, description: req.description, ingredients: req.ingredients, coreMLIdentifier: req.coreMLIdentifier, updatedAt: moment().format() }, { condition: 'attribute_exists(uid)' }) .then((err) => { console.error(err); }) }; But the control always kept going out of context and never entered .then()Appreciate the helpThank you.
Submitted February 14, 2019 at 03:51PM by rkreloaded
No comments:
Post a Comment