有人可以解释如何使用Node.js修复丢失的配置错误吗?我已经按照aws doc页面中的所有示例进行了操作,但无论如何我仍然会收到此错误.
{ [ConfigError: Missing region in config]
message: 'Missing region in config',
code: 'ConfigError',
time: Wed Jun 24 2015 21:39:58 GMT-0400 (EDT) }>{ thumbnail:
{ fieldname: 'thumbnail',
originalname: 'testDoc.pdf',
name: 'testDoc.pdf',
encoding: '7bit',
mimetype: 'application/pdf',
path: 'uploads/testDoc.pdf',
extension: 'pdf',
size: 24,
truncated: false,
buffer: null } }
POST / 200 81.530 ms - -
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
var express = require('express');
var router = express.Router();
var AWS = require('aws-sdk');
var dd = new AWS.DynamoDB();
var s3 = new AWS.S3(); …Run Code Online (Sandbox Code Playgroud) 我正在使用aws-sdk javascript我的后端,我可以使用AWS正常,但当我尝试使用该getOpenIdTokenForDeveloperIdentity方法时,我得到"Missing region in config error"一个响应.
var config = new AWS.Config({
accessKeyId: "MYACCESSKEY", secretAccessKey: "MYSECRETYKEY", region: 'us-east-1'
});
var params = {
IdentityPoolId: 'MYIDENTITYPOOLID', /* required */
Logins: { /* required */
"login.my.myapp": 'string',
/* anotherKey: ... */
},
IdentityId: null,
TokenDuration: 0
};
cognitoidentity.getOpenIdTokenForDeveloperIdentity(params,function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
Run Code Online (Sandbox Code Playgroud)
在文档中它说:
默认情况下,凭据和区域设置保持未配置状态.在使用任何AWS服务API之前,应由应用程序配置此项.
所以我设置了我的区域,但为什么我仍然收到错误?