example on dynamo not working #9

Closed
kyleroche opened this Issue Dec 16, 2012 · 10 comments

Comments

Projects
None yet
2 participants

Trying to get the example running for dynamo:
db = new AWS.DynamoDB()
# db = new AWS.DynamoDB()
db.client.listTables (err, data) ->
console.log resp.data.TableNames

I'm getting a TypeError. Not a string or buffer

Do you have a working example of a Dynamo Call you can post?

Contributor

lsegal commented Dec 16, 2012

The example wasn't fully updated with the Api changes, but if you simply remove resp it should work.

Thanks for the quick reply... same error:
TypeError: Not a string or buffer

db = new AWS.DynamoDB()
# db = new AWS.DynamoDB()
db.client.listTables (err, data) ->
console.log data.TableNames

actually, just this will cause it:
db = new AWS.DynamoDB()
db.client.listTables (err, data) ->
# nothing

Contributor

lsegal commented Dec 16, 2012

What happens if you log only data? If an error occurred, the value may be null. You should always check err before using data.

i tried logging err and data alone as well. even w/ an empty function i am getting the error.

Contributor

lsegal commented Dec 16, 2012

What is the result of AWS.VERSION?

AWS: 0.9.1-pre.2

Contributor

lsegal commented Dec 16, 2012

I see what the issue is-- you likely have not set your region or your credentials. We are working on making the error message more obvious for this one, but the solution is to set the region via AWS.config.update. This is documented at the top of the Examples section in the guides. Something like the following should work (assuming your credentials are set via envrionment variables):

var AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});
Contributor

lsegal commented Dec 16, 2012

I've opened an issue for the unintuitive error at #10. I will also correct the example documentation.

@lsegal lsegal pushed a commit that referenced this issue Dec 16, 2012

Loren Segal Correct some examples in guide documentation
References #9
6417d9d

Region config fixed it. Thanks for the quick reply

kyleroche closed this Dec 16, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment