问题描述
我看到此错误
A function whose declared type is neither 'void' nor 'any' must return a value.ts
当我执行以下代码时。我正在通过全球二级索引从Dynamo检索,并且从Dynamo获得的项目非常好。我返回Employee作为响应,但是我收到此错误。请帮助下面是我的代码。
async getByIndex(index: string): Promise<Employee> {
const params = {
TableName: table-name,IndexName: indexName,KeyConditionExpression: expression,ExpressionAttributeValues: {
values
},};
const response = await this.dynamoDocumentClient.query(params).promise();
if (!response?.Items) {
throw new NotFoundException('id');
}
response.Items.forEach((item) => {
return item as Employee;
});
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)