UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

13 lines (12 loc) 578 B
export const putEntity = async ({ awsAccountId, awsRegion, tableName, ...entity }, { apiUrl, fetch: _fetch = fetch, apiKey }) => { const response = await _fetch([apiUrl, 'table', awsAccountId, awsRegion, tableName, 'entity'].join('/'), { method: 'PUT', headers: { Authorization: apiKey }, body: JSON.stringify(entity), signal: AbortSignal.timeout(30000) }); if (!response.ok) { const { message, Message } = (await response.json()); throw new Error(message !== null && message !== void 0 ? message : Message); } };