diff --git a/functions/todos-create.js b/functions/todos-create.js index a657b46..5b244a4 100644 --- a/functions/todos-create.js +++ b/functions/todos-create.js @@ -13,9 +13,15 @@ exports.handler = (event, context, callback) => { return client.query(q.Create(q.Ref("classes/todos"), {data})) .then((response) => { console.log("success", response); - callback(false, response); + return callback(null, { + statusCode: 200, + body: JSON.stringify(response) + }) }).catch((error) => { console.log("error", error); - callback(error) + return callback(null, { + statusCode: 400, + body: JSON.stringify(error) + }) }) }; diff --git a/functions/todos-delete.js b/functions/todos-delete.js index 981db69..400d197 100644 --- a/functions/todos-delete.js +++ b/functions/todos-delete.js @@ -12,9 +12,15 @@ exports.handler = (event, context, callback) => { return client.query(q.Delete(q.Ref("classes/todos/"+event.pathParameters.id))) .then((response) => { console.log("success", response); - callback(false, response); + return callback(null, { + statusCode: 200, + body: JSON.stringify(response) + }) }).catch((error) => { console.log("error", error); - callback(error) + return callback(null, { + statusCode: 400, + body: JSON.stringify(error) + }) }) }; diff --git a/functions/todos-read-all.js b/functions/todos-read-all.js index f69162a..53f1104 100644 --- a/functions/todos-read-all.js +++ b/functions/todos-read-all.js @@ -12,9 +12,15 @@ exports.handler = (event, context, callback) => { return client.query(q.Paginate(q.Match(q.Ref("indexes/all_todos")))) .then((response) => { console.log("success", response); - callback(false, response); + return callback(null, { + statusCode: 200, + body: JSON.stringify(response) + }) }).catch((error) => { console.log("error", error); - callback(error) + return callback(null, { + statusCode: 400, + body: JSON.stringify(error) + }) }) }; diff --git a/functions/todos-read-one.js b/functions/todos-read-one.js index df95a52..7334453 100644 --- a/functions/todos-read-one.js +++ b/functions/todos-read-one.js @@ -12,9 +12,15 @@ exports.handler = (event, context, callback) => { return client.query(q.Get(q.Ref("classes/todos/"+event.pathParameters.id))) .then((response) => { console.log("success", response); - callback(false, response); + return callback(null, { + statusCode: 200, + body: JSON.stringify(response) + }) }).catch((error) => { console.log("error", error); - callback(error) + return callback(null, { + statusCode: 400, + body: JSON.stringify(error) + }) }) }; diff --git a/functions/todos-update.js b/functions/todos-update.js index ea5f5a9..e69dc58 100644 --- a/functions/todos-update.js +++ b/functions/todos-update.js @@ -13,9 +13,15 @@ exports.handler = (event, context, callback) => { return client.query(q.Update(q.Ref("classes/todos/"+event.pathParameters.id), {data})) .then((response) => { console.log("success", response); - callback(false, response); + return callback(null, { + statusCode: 200, + body: JSON.stringify(response) + }) }).catch((error) => { console.log("error", error); - callback(error) + return callback(null, { + statusCode: 400, + body: JSON.stringify(error) + }) }) };