Created
November 1, 2022 09:57
-
-
Save cal0610/b637702e0116f47b8b613c1ae1845c6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as AWS from 'aws-sdk'; | |
const TABLE_NAME = process.env.STORE_TABLE_NAME || ''; | |
const db = new AWS.DynamoDB.DocumentClient(); | |
export const handler = async (event: any): Promise<any> => { | |
const params = { | |
TableName: TABLE_NAME, | |
}; | |
try { | |
const response = await db.scan(params).promise(); | |
return { | |
statusCode: 200, | |
headers: { | |
'Access-Control-Allow-Origin': '*', | |
}, | |
body: JSON.stringify(response.Items), | |
}; | |
} catch (dbError: any) { | |
return { statusCode: 500, body: JSON.stringify(dbError) }; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment