Untitled
unknown
plain_text
a year ago
1.1 kB
5
Indexable
// Lambda function to store user information in DynamoDB const AWS = require('aws-sdk'); const dynamodb = new AWS.DynamoDB.DocumentClient(); exports.handler = async (event) => { // Parse data from the request body const { name, email, password } = JSON.parse(event.body); // DynamoDB parameters const params = { TableName: 'user_info', // Replace with your DynamoDB table name Item: { email: email, name: name, password: password } }; try { // Put item in DynamoDB table await dynamodb.put(params).promise(); // Return success response return { statusCode: 200, body: JSON.stringify({ message: 'User information saved successfully' }) }; } catch (error) { // Return error response console.error('Error saving data: ', error); return { statusCode: 500, body: JSON.stringify({ message: 'Error saving user information' }) }; } };
Editor is loading...
Leave a Comment