【问题标题】:Error using JavaScript SDK for AlexaForBusiness为 AlexaForBusiness 使用 JavaScript SDK 时出错
【发布时间】:2021-09-13 18:43:38
【问题描述】:

在尝试使用下面的示例代码时需要帮助解决我遇到的错误:

    var aws = require('aws-sdk');
    const alexaforbusiness = new aws.AlexaForBusiness({ region: "us-east-1" });
    
    export async function main(event, context) {
        try{
            var params = {
                UserId: event.body.uid,
                Email: event.body.email,
                FirstName: event.body.FirstName,
                LastName: event.body.LastName,
                Tags: [{
                    Key: event.body.tag,
                    Value: event.body.tagVal
                 },
                 ]
            };
            var cData = await alexaforbusiness.createUser(params);
        }
        catch(err){
             console.log(err, err.stack); 
        }
    }

我收到以下错误:

err.message : Converting circular structure to JSON
--> starting at object with constructor 'Request'
|     property 'response' -> object with constructor 'Response'
--- property 'request' closes the circle

谢谢!!

【问题讨论】:

    标签: aws-lambda aws-sdk alexa-for-business


    【解决方案1】:

    根据AWS Documentation,AlexaForBusiness 的 V2 SDK 的 async/await 样式应该可以工作,但只有 API 的回调样式可以工作。

    const alexaforbusiness = new aws.AlexaForBusiness({ apiVersion: '2017-11-09', region: "YOUR_REGION" });    
    var params = {
          UserId: 'STRING_VALUE', /* required */
          ClientRequestToken: 'STRING_VALUE',
          Email: 'STRING_VALUE',
          FirstName: 'STRING_VALUE',
          LastName: 'STRING_VALUE',
          Tags: [
            {
              Key: 'STRING_VALUE', /* required */
              Value: 'STRING_VALUE' /* required */
            },
            /* more items */
          ]
        };
        alexaforbusiness.createUser(params, function(err, data) {
          if (err) console.log(err, err.stack); // an error occurred
          else     console.log(data);           // successful response
        });
    

    【讨论】:

      猜你喜欢
      • 2013-02-11
      • 1970-01-01
      • 1970-01-01
      • 2022-11-09
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      • 2018-08-11
      • 1970-01-01
      相关资源
      最近更新 更多