我正在Typescript中设置一个node.js服务器,并且在AWS上有一个DynamoDB,我要做的就是用'put'创建/更新项目,并用'get'进行检索。
我已经用纯JavaScript制作了测试服务器,并且一切正常,但是当我尝试在Typescript中执行完全相同的操作时,不会调用回调,并且在控制台中也不会出现任何错误
import { DynamoDB } from 'aws-sdk'
const client = new DynamoDB.DocumentClient({ region: 'eu-west-3'})
const params = {
TableName: "Movies",
Item: {
"primary": "foo",
"range": 123,
"text": "bar"
}
}
client.put(params, (err, data) => {
console.log('done')
})
已编译的Javascript:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const aws_sdk_1 = require("aws-sdk");
const client = new aws_sdk_1.DynamoDB.DocumentClient();
const params = {
TableName: "Movies",
Item: {
"primary": "foo",
"range": 123,
"text": "bar"
}
};
client.put(params).promise().then(res => console.log(res)).catch(err => console.log(err)).finally(() => console.log('finally'));
//# sourceMappingURL=app.js.map