嘗試向sq發送消息時,我收到一條丟失的配置憑據警告。如果切換到只顯示我的accesskey和密碼,我可以發送消息到sqs就好了。我已經包含了我使用的代碼和從下面的瀏覽器中獲得的錯誤。下面使用cognito進行身份驗證時向SQS發送消息
代碼:從執行console.log
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'xxxxxx',
});
var params = {
MessageBody: 'some random message',
QueueUrl: 'xxxxxx'
};
AWS.config.credentials.get(function(err) {
if (err) console.log(err);
else console.log(AWS.config.credentials);
});
var sqs = new AWS.SQS();
sqs.sendMessage(params, function (err, data) {
if (!err) {
console.log('Message sent.');
} else {
console.log(err);
}
});
錯誤:
錯誤:在零配置 丟失區域。 (https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:5:10470) 在r.SequentialExecutor.r.util.inherit.callListeners(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:27635) 在r.SequentialExecutor.r.util.inherit.emit(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:27431) 在n.Request.o.emitEvent(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:15837) E處(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:12148) 在r.runTo(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:7:23197) 在n.Request.o.runTo(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:13657) 在n.Request.o.send(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:13550) 在t.Service.i.makeUnauthenticatedRequest(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:30572) 在t .util.update.getId(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:7:2224) index.html:57錯誤:配置文件 中缺少憑據。 (https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:5:10470) 在r.SequentialExecutor.r.util.inherit.callListeners(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:27635) 在r.SequentialExecutor.r.util.inherit.emit(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:27431) 在n.Request.o.emitEvent(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:15837) E處(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:12148) 在r.runTo(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:7:23197) 在n.Request.o.runTo(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:13657) 在n.Request.o.send(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:13550) 在t.Service.i.makeUnauthenticatedRequest(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:6:30572) 在t .util.update.getId(https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js:7:2224)
注意:我嘗試過用不同的方式添加區域。
我使用該代碼嘗試,但它抱怨的區域被設置。我不使用節點,這只是在瀏覽器JavaScript。 – user3662516
當您嘗試設置區域時,您可以發佈您的代碼以及產生的錯誤消息嗎? – jarmod