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({
|
||||
|
|
@ -7,7 +8,7 @@ const client = new faunadb.Client({
|
|||
|
||||
exports.handler = (event, context, callback) => {
|
||||
const data = JSON.parse(event.body)
|
||||
const id = event.path.replace(/\/\.netlify\/functions\/todos-update\//, "")
|
||||
const id = getId(event.path)
|
||||
console.log(`Function 'todo-update' invoked. update id: ${id}`)
|
||||
return client.query(q.Update(q.Ref(`classes/todos/${id}`), {data}))
|
||||
.then((response) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue