我試圖與DynamoDB競爭節點js亞馬遜開始指南。我試圖創建一個表,但這裏是錯誤我已經:DynamoDB和節點Js:意外的令牌h
Unable to create table. Error JSON: {
"message": "Unexpected token h",
"code": "SyntaxError",
"time": "2016-05-06T16:59:50.411Z",
"statusCode": 200,
"retryable": false,
"retryDelay": 0
我正在以下節點(直接從亞馬遜入門指南拍攝):
var AWS = require("aws-sdk");
AWS.config.loadFromPath('./.aws/credentials.json');
AWS.config.update({
region: "us-west-2",
endpoint: "http://localhost:8000"
});
var dynamodb = new AWS.DynamoDB();
var params = {
TableName : "Movies",
KeySchema: [
{ AttributeName: "year", KeyType: "HASH"}, //Partition key
{ AttributeName: "title", KeyType: "RANGE" } //Sort key
],
AttributeDefinitions: [
{ AttributeName: "year", AttributeType: "N" },
{ AttributeName: "title", AttributeType: "S" }
],
ProvisionedThroughput: {
ReadCapacityUnits: 10,
WriteCapacityUnits: 10
}
};
dynamodb.createTable(params, function(err, data) {
if (err) {
console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
}
});
我已經根據本教程在端口8080上運行本地Web服務器:https://www.youtube.com/watch?v=pU9Q6oiQNd0。它似乎工作正常。
謝謝。
我會檢查'./ AWS/credentials.json'是有效的JSON(雙引號屬性名稱等) –
感謝。這裏是我在那裏: {「accessKeyId」:「XXXXXXXXXXXXX」,「secretAccessKey」:「XXXXXXXXXXXXXXXXXXXXXXX」,「region」:「us-east-1」} –