在 simpledb 中运行 select 并使用 node.js 给出错误
我正在运行以下代码: https://github.com/rjrodger/simpledb
var simpledb = require('simpledb');
var sys = require('sys');
sdb = new simpledb.SimpleDB({keyid:'kye'
,secret:'mysectkey'});
var str="select * from youngib where createdon is not null order by createdon desc limit 10";
sdb.select (str, function( error, result ) {
console.log('attr1 = '+sys.inspect(error));
console.log('result = '+sys.inspect(result));
});
如果我在单独的文件中运行它,它就会运行,但如果我在我的项目中运行它给了我这个错误,为什么会出现这个错误?
{ Code: 'SignatureDoesNotMatch',
Message: 'The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.' }
问题是我已经声明
Array.prototype.in_array = function(p_val) {
for(var i = 0, l = this.length; i < l; i++) {
if(this[i] == p_val) {
return true;
}
}
return false;
}
由于这个原因它没有执行 simpledb ,我不知道为什么,如果你知道请告诉我。
I am running following code :
https://github.com/rjrodger/simpledb
var simpledb = require('simpledb');
var sys = require('sys');
sdb = new simpledb.SimpleDB({keyid:'kye'
,secret:'mysectkey'});
var str="select * from youngib where createdon is not null order by createdon desc limit 10";
sdb.select (str, function( error, result ) {
console.log('attr1 = '+sys.inspect(error));
console.log('result = '+sys.inspect(result));
});
if i run this in seperate file it run but if i run in my project it gives me this error ,why this error coming?
{ Code: 'SignatureDoesNotMatch',
Message: 'The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.' }
the problem was that there i have declare
Array.prototype.in_array = function(p_val) {
for(var i = 0, l = this.length; i < l; i++) {
if(this[i] == p_val) {
return true;
}
}
return false;
}
due to this it was not executing the simpledb , i don't know why, if you know please tell me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果扩展 Array.prototype ,您可能会遇到 for ... in 循环问题。
例如:
for in 循环迭代所有属性。因此,基本上,您的第 3 方代码假设您没有在 Array.prototype 上进行扩展。
由于这些原因,扩展本机原型是不好的做法。
至于您的
in_array
方法,您可以改为使用。
If you extend
Array.prototype
you can get issues withfor ... in
loops.For example:
The for in loop iterates over all properties. So basically your 3rd party code makes the assumption you have not extend on
Array.prototype
.Extending native prototypes is bad practice for these reasons.
As for your
in_array
method you could useinstead.