Merge branch 'master' of github.com:netlify/netlify-faunadb-example
# Conflicts: # package.json # src/App.js # src/setupProxy.js
This commit is contained in:
commit
65522c08ec
2 changed files with 19 additions and 19 deletions
|
|
@ -10,25 +10,25 @@ const client = new faunadb.Client({
|
||||||
exports.handler = (event, context, callback) => {
|
exports.handler = (event, context, callback) => {
|
||||||
/* parse the string body into a useable JS object */
|
/* parse the string body into a useable JS object */
|
||||||
const data = JSON.parse(event.body)
|
const data = JSON.parse(event.body)
|
||||||
console.log("Function `todo-create` invoked", data)
|
console.log('Function `todo-create` invoked', data)
|
||||||
const todoItem = {
|
const todoItem = {
|
||||||
data: data
|
data: data
|
||||||
}
|
}
|
||||||
/* construct the fauna query */
|
/* construct the fauna query */
|
||||||
return client.query(q.Create(q.Ref("classes/todos"), todoItem))
|
return client.query(q.Create(q.Ref('classes/todos'), todoItem))
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log("success", response)
|
console.log('success', response)
|
||||||
/* Success! return the response with statusCode 200 */
|
/* Success! return the response with statusCode 200 */
|
||||||
return callback(null, {
|
return callback(null, {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
body: JSON.stringify(response)
|
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)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}).catch((error) => {
|
|
||||||
console.log("error", error)
|
|
||||||
/* Error! return the error with statusCode 400 */
|
|
||||||
return callback(null, {
|
|
||||||
statusCode: 400,
|
|
||||||
body: JSON.stringify(error)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const proxy = require('http-proxy-middleware');
|
const proxy = require('http-proxy-middleware')
|
||||||
|
|
||||||
module.exports = function(app) {
|
module.exports = function(app) {
|
||||||
app.use(
|
app.use(
|
||||||
|
|
@ -8,5 +8,5 @@ module.exports = function(app) {
|
||||||
'^/\\.netlify/functions': ''
|
'^/\\.netlify/functions': ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
)
|
||||||
};
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue