update function name
This commit is contained in:
parent
d4c3868e20
commit
943865b2c1
1 changed files with 1 additions and 1 deletions
25
functions/todos-read.js
Normal file
25
functions/todos-read.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import faunadb from 'faunadb'
|
||||
|
||||
const q = faunadb.query
|
||||
const client = new faunadb.Client({
|
||||
secret: process.env.FAUNADB_SECRET
|
||||
})
|
||||
|
||||
exports.handler = (event, context, callback) => {
|
||||
const id = event.path.replace(/\/\.netlify\/functions\/todos-read\//, "")
|
||||
console.log(`readOne todo ${id}`)
|
||||
return client.query(q.Get(q.Ref(`classes/todos/${id}`)))
|
||||
.then((response) => {
|
||||
console.log("success", response)
|
||||
return callback(null, {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify(response)
|
||||
})
|
||||
}).catch((error) => {
|
||||
console.log("error", error)
|
||||
return callback(null, {
|
||||
statusCode: 400,
|
||||
body: JSON.stringify(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue