fix ID reference
This commit is contained in:
parent
4f616b21a1
commit
d4c3868e20
5 changed files with 43 additions and 52 deletions
|
|
@ -1,26 +1,25 @@
|
|||
'use strict';
|
||||
|
||||
import faunadb from 'faunadb'
|
||||
// const faunadb = require('faunadb');
|
||||
const q = faunadb.query;
|
||||
|
||||
const q = faunadb.query
|
||||
const client = new faunadb.Client({
|
||||
secret: process.env.FAUNADB_SECRET
|
||||
});
|
||||
})
|
||||
|
||||
exports.handler = (event, context, callback) => {
|
||||
console.log("delete todo");
|
||||
return client.query(q.Delete(q.Ref("classes/todos/"+event.pathParameters.id)))
|
||||
const id = event.path.replace(/\/\.netlify\/functions\/todos-delete\//, "")
|
||||
console.log("delete todo", id)
|
||||
return client.query(q.Delete(q.Ref(`classes/todos/${id}`)))
|
||||
.then((response) => {
|
||||
console.log("success", response);
|
||||
console.log("success", response)
|
||||
return callback(null, {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify(response)
|
||||
})
|
||||
}).catch((error) => {
|
||||
console.log("error", 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