{ошибка: не удается прочитать свойство playerId, равное нулю}
Я создал лямбда-функцию списка
который передается в playerId. Этот playerId используется так.
export const main = handler(async (event, context) => {
const data = JSON.parse(event.body);
const params = {
TableName: process.env.teamsTable,
ExpressionAttributeValues : {
':playerId' : { S: data.playerId }
},
FilterExpression: "contains (players, :playerId)"
};
try {
const result = await dynamoDb.scan(params);
if (!result.Items) {
throw new Error("Teams not found.");
}
return {
status: 200,
body: result.Items,
};
} catch (e) {
return {
statusCode: 500,
body: JSON.stringify({ error: e.message }),
};}});
Я протестировал его локально с помощью бессерверных моков, и он работает. Создайте вызов, чтобы использовать его в FE и получить следующую ошибку: {error: Cannot read property 'playerId' of null} error: Cannot read property 'playerId' of null, also hit it through API gateway and hit the same. вызов frontEnd -
const endpoint = "/teams";
console.log(playerId);
try {
const response = await API.get(amplifyAPIName, endpoint, {
body: playerId
});
return response;
} catch {
return [];
}
}
помощь
GET
? - person Zem   schedule 12.03.2021