0
AWS SAM 로컬에서 AWS Cognito 로그인 프로세스 인증 API를 실행하고 있습니다. 나는 Cognito에서 제대로 표식을 얻고 있지만 signInUser 약속이 올바른 응답으로 해결되면 statusCode가 200으로 콜백되는 대신 콜백 (statusCode가 400)과 함께 콜백이 발생합니다. 여기람다 콜백이 작동하지 않는 이유는 무엇입니까?
참조 람다 기능 : -
// A signin Lambda function
export function handler (event: Object, context: Object, callback: Function) {
switch (event.httpMethod) {
case "GET":
// hard code login for SO question
signInUser({ username: 'XXXX', password: 'XXXXXXX'})
.then((response) => {
console.log('This log is called correctly but callback on the next line is not');
callback(null, {
statusCode: 200,
header: response.tokens.idToken.jwtToken,
body: "This is a signin operation, return success result"
});
})
.catch(
callback(null, {
statusCode: 400,
body: "This is a failed signin operation"
})
);
break;
default:
// Send HTTP 501: Not Implemented
console.log("Error: unsupported HTTP method (" + event.httpMethod + ")");
callback(null, {statusCode: 501})
}
}
이런 일이 원인이나 해결 방법을하는 무엇 어떤 아이디어가?
감사합니다.
'catch '함수를'catch'함수에 전달한 방법이 잘못되었습니다. –