add path id util

This commit is contained in:
davidwells 2018-06-11 21:26:54 -07:00
parent 4c794b23f3
commit 5a0a7e495c
5 changed files with 16 additions and 7 deletions

View file

@ -1,4 +1,5 @@
import faunadb from 'faunadb'
import getId from './utils/getId'
const q = faunadb.query
const client = new faunadb.Client({
@ -6,7 +7,7 @@ const client = new faunadb.Client({
})
exports.handler = (event, context, callback) => {
const id = event.path.replace(/\/\.netlify\/functions\/todos-read\//, "")
const id = getId(event.path)
console.log(`Function 'todo-read' invoked. Read id: ${id}`)
return client.query(q.Get(q.Ref(`classes/todos/${id}`)))
.then((response) => {