-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Page: /guides/functions/dynamodb-from-js-lambda/q/platform/[platform]
Feedback:
It seems to me that code samples for the Node.js are a bit frustrating on the try catch blocks
- with this sample the error will end up in the
body
attribute of the response
async function getItem(){
try {
const data = await docClient.get(params).promise()
return data
} catch (err) {
return err
}
}
exports.handler = async (event, context) => {
try {
const data = await getItem()
return { body: JSON.stringify(data) }
} catch (err) {
return { error: err }
}
}
I know that it's to show the general approach only, but I would still suggest to remove the getItem as a separate function, or to add some ifs in the main function to handle the getItem returned value
Sorry if I miss something here