I’m trying to do a batchget on dynamodb by parsing a query string into the Keys property of params for a batchget.
if (playlistState == "link") {
const tracksArray = _parseTracksQuery(event.queryStringParameters.tracks);
const theKeys = _createTracksQueryKeys(tracksArray);
let params = {
RequestItems: {
'activeMusicCatalog': {
Keys : theKeys
}
}
};
dynamoDB.batchGet(params, function (err, result) {
if (err) {
console.log(err); // an error occurred
callback(new Error('Cant fetch tracks'))
return;
}
let response = {
statusCode: 200,
headers: {
"Access-Control-Allow-Origin": "*"
},
body: JSON.stringify(result.Responses.activeMusicCatalog)
};
callback(null, response);
});
}
When I do a local invoke of the function it works, when I do a curl of only one item, it works, when I hard code tracks into the Keys like below it works both in curl and local invoke.
if (playlistState == "link") {
const tracksArray = _parseTracksQuery(event.queryStringParameters.tracks);
const theKeys = _createTracksQueryKeys(tracksArray);
let params = {
RequestItems: {
'activeMusicCatalog': {
Keys: [
{
Album: "misc",
Track: "fuzzy-chaos"
},
{
Album: "cinematic-spy",
Track: "waiting-game"
}
]
}
}
};
But when I create the array of objects from multiple tracks it returns an empty array with curl/browser.
…any ideas?