add path id util
This commit is contained in:
parent
4c794b23f3
commit
5a0a7e495c
5 changed files with 16 additions and 7 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue