update readme

This commit is contained in:
DavidWells 2018-07-01 18:10:12 -07:00
parent cede6634d1
commit cc26558ff1
8 changed files with 28 additions and 22 deletions

View file

@ -1,12 +1,14 @@
/* Import faunaDB sdk */
import faunadb from 'faunadb'
import faunadb from 'faunadb' /* Import faunaDB sdk */
/* configure faunaDB Client with our secret */
const q = faunadb.query
const client = new faunadb.Client({
secret: process.env.FAUNADB_SECRET
})
/* export our lambda function as named "handler" export */
exports.handler = (event, context, callback) => {
/* parse the string body into a useable JS object */
const data = JSON.parse(event.body)
console.log("Function `todo-create` invoked", data)
const todoItem = {
@ -16,12 +18,14 @@ exports.handler = (event, context, callback) => {
return client.query(q.Create(q.Ref("classes/todos"), todoItem))
.then((response) => {
console.log("success", response)
/* Success! return the response with statusCode 200 */
return callback(null, {
statusCode: 200,
body: JSON.stringify(response)
})
}).catch((error) => {
console.log("error", error)
/* Error! return the error with statusCode 400 */
return callback(null, {
statusCode: 400,
body: JSON.stringify(error)

View file

@ -1,4 +1,3 @@
/* Import faunaDB sdk */
import faunadb from 'faunadb'
import getId from './utils/getId'

View file

@ -1,4 +1,3 @@
/* Import faunaDB sdk */
import faunadb from 'faunadb'
import getId from './utils/getId'

View file

@ -1,4 +1,3 @@
/* Import faunaDB sdk */
import faunadb from 'faunadb'
const q = faunadb.query

View file

@ -1,4 +1,3 @@
/* Import faunaDB sdk */
import faunadb from 'faunadb'
import getId from './utils/getId'

View file

@ -1,4 +1,3 @@
/* Import faunaDB sdk */
import faunadb from 'faunadb'
import getId from './utils/getId'