diff --git a/functions/todos-create.js b/functions/todos-create.js index a0333fa..2c23a40 100644 --- a/functions/todos-create.js +++ b/functions/todos-create.js @@ -7,7 +7,7 @@ const client = new faunadb.Client({ exports.handler = (event, context, callback) => { const data = JSON.parse(event.body) - console.log("Function `todo-create` invoked") + console.log("Function `todo-create` invoked", data) return client.query(q.Create(q.Ref("classes/todos"), {data})) .then((response) => { console.log("success", response) diff --git a/functions/todos-read-all.js b/functions/todos-read-all.js index 14076ed..662995f 100644 --- a/functions/todos-read-all.js +++ b/functions/todos-read-all.js @@ -10,9 +10,16 @@ exports.handler = (event, context, callback) => { return client.query(q.Paginate(q.Match(q.Ref("indexes/all_todos")))) .then((response) => { console.log("success", response) - return callback(null, { - statusCode: 200, - body: JSON.stringify(response) + const newQuery = response.data.map((ref) => { + console.log('ref', ref) + return q.Get(ref) + }) + // then query the refs + return client.query(newQuery).then((ret) => { + return callback(null, { + statusCode: 200, + body: JSON.stringify(ret) + }) }) }).catch((error) => { console.log("error", error)