I'm trying to convert my dynamodb operation (put) to something of a synchronous nature. For example, I was able to do it with the Request library:
original:
//Lets configure and request
request({
url: 'https://www.google.com', //URL to hit
method: 'POST',
//Lets post the following key/values as form
form: {
key: value
}
}, function(error, response, body){
if(error) {
callback(error, null);
} else {
callback(null, 'good job!');
}
});
converted:
var response;
try{
response = request({
url: 'https://www.google.com', //URL to hit
method: 'POST',
//Lets post the following key/values as form
form: {
key: value
}
});
} catch(err)
{
console.log(err);
return err;
}
return response;
I have this code for AWS that I'm trying to convert but the problem is I can't seem to parse the response to ensure whether or not an error occurred.
var params = {
Item: {
key: value
},
TableName: 'myTable'
};
var response = docClient.put(params);
return response;
The response I get is always the same regardless of me tampering with the table name or anything. Anyone know how to convert this to a synchronous operation? Thanks!
via booky99
No comments:
Post a Comment