首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SDK的问题:amazon-cognito identity-js

SDK的问题:amazon-cognito identity-js
EN

Stack Overflow用户
提问于 2019-08-02 22:19:27
回答 1查看 76关注 0票数 0

我从aws-cognito开始。我已经在亚马逊平台上创建了一个UserPool和一个UserPoolClient。我正在实现一个执行用户注册的lambda (作为测试)。但是尝试用邮递员运行它时,会返回"Internal Server Error“。这是我的Lambda的代码。

代码语言:javascript
复制
module.exports.register = async event => {

  var AmazonCognitoIdentity = require('amazon-cognito-identity-js');
  var CognitoUserPool = AmazonCognitoIdentity.CognitoUserPool;

  var poolData = {
    UserPoolId: '...', // Here, I put my UserPoolId
    ClientId: '...' // Here, I put my ClientId
  };
  var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
  var attributeList = [];

  var dataEmail = {
    Name: 'email',
    Value: 'myemail@gmail.com'
  };

  var dataPhoneNumber = {
    Name: 'phone_number',
    Value: '+15555555555'
  };
  var attributeEmail = new AmazonCognitoIdentity.CognitoUserAttribute(dataEmail);
  var attributePhoneNumber = new AmazonCognitoIdentity.CognitoUserAttribute(dataPhoneNumber);

  attributeList.push(attributeEmail);
  attributeList.push(attributePhoneNumber);
  var cognitoUser = ''
  userPool.signUp('myemail@gmail.com', 'MyPassword7.com', attributeList, null, function (err, result) {
    if (err) {
      cognitoUser = err;
    }
    cognitoUser = result.user;
  });
  return {
    statusCode: 200,
    body: JSON.stringify(
      {
        message: 'Go Serverless v1.0! Your function executed successfully!',
        input: event,
        cognitoUser: cognitoUser
      },
      null,
      2
    ),
  };
EN

回答 1

Stack Overflow用户

发布于 2019-08-03 06:50:25

我认为您需要在响应中添加适当的标头

代码语言:javascript
复制
      headers: {
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Allow-Credentials': true,
        'Content-Type': 'application/json',
      },
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57328325

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档