How to return from nested function in Node.js?
问题 I'm wrapping my dynamoDB function into another function and I'm having issues with returning it to the "item" const. What I'm missing here? Works: const params = { TableName: table, Key: { id: id }, }; dynamoDb.get(params, (error, result) => { if (error) { console.error(error); callback(null, { statusCode: error.statusCode || 501, body: 'Couldn\'t fetch the item.', }); return; } const item = result.Item }) Doesn't work (returns undefinied): const getFromDb = () => { const params = { TableName