Angular 您是否了解lambda函数的此POST请求的问题?

Angular 您是否了解lambda函数的此POST请求的问题?,angular,post,httprequest,netlify,faunadb,Angular,Post,Httprequest,Netlify,Faunadb,我在项目中使用netlify lambda函数进行CRUD操作,但在POST操作中出现错误 我使用角度前端、netlify函数和faunaDB 我的lambda: /* code from functions/todos-create.js */ import faunadb from 'faunadb' /* Import faunaDB sdk */ /* configure faunaDB Client with our secret */ const q = faunadb.query

我在项目中使用netlify lambda函数进行CRUD操作,但在POST操作中出现错误

我使用角度前端、netlify函数和faunaDB

我的lambda:

/* code from functions/todos-create.js */
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 */
  console.log('<<<<<<<<<' + "      " + event.body + "       " + '>>>>>>>>>')
  const eventBody = JSON.stringify(event.body)
  const data = JSON.parse(eventBody)
  console.log("Function `todo-create` invoked", data)
  const todoItem = {
    data: data
  }
  /* construct the fauna query */
  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)
    })
  })
}
我的服务:

  createTodo(data) {
    console.log('console log of createTodo ---->');
    console.log(data);
    return fetch('/.netlify/functions/todos-create', {
      body: JSON.stringify(data),
      method: 'POST'
    }).then(response => {
      return response.json();
    });
  }
最后是执行错误

Request from ::ffff:127.0.0.1: POST /todos-create
[BACK] [LAMBDA] <<<<<<<<<      {"title":"What I had for breakfast ..","completed":true}       >>>>>>>>>
[BACK] [LAMBDA] Function `todo-create` invoked {"title":"What I had for breakfast ..","completed":true}
[BACK] [LAMBDA] error { [BadRequest: validation failed]
[BACK] [LAMBDA]   name: 'BadRequest',
[BACK] [LAMBDA]   message: 'validation failed',
[BACK] [LAMBDA]   requestResult:
[BACK] [LAMBDA]    RequestResult {
[BACK] [LAMBDA]      client:
[BACK] [LAMBDA]       Client {
[BACK] [LAMBDA]         _baseUrl: 'https://db.fauna.com:443',
[BACK] [LAMBDA]         _timeout: 60000,
[BACK] [LAMBDA]         _secret: '******************'
[BACK] [LAMBDA]         _observer: null,
[BACK] [LAMBDA]         _lastSeen: 1559144535321508 },
[BACK] [LAMBDA]      method: 'POST',
[BACK] [LAMBDA]      path: '',
[BACK] [LAMBDA]      query: null,
[BACK] [LAMBDA]      requestRaw: undefined,
[BACK] [LAMBDA]      requestContent: Expr { raw: [Object] },
[BACK] [LAMBDA]      responseRaw:
[BACK] [LAMBDA]       '{"errors":[{"position":[],"code":"validation failed","description":"Instance data is not valid.","failures":[{"field":["data"],"code":"invalid type","description":"Invalid type String, expected type Map."}]}]}',
[BACK] [LAMBDA]      responseContent: { errors: [Array] },
[BACK] [LAMBDA]      statusCode: 400,
[BACK] [LAMBDA]      responseHeaders:
[BACK] [LAMBDA]       { 'content-type': 'application/json;charset=utf-8',
[BACK] [LAMBDA]         date: 'Wed, 29 May 2019 15:42:15 GMT',
[BACK] [LAMBDA]         'x-bus-bytes-in': '0',
[BACK] [LAMBDA]         'x-bus-bytes-out': '0',
[BACK] [LAMBDA]         'x-bus-messages-in': '0',
[BACK] [LAMBDA]         'x-bus-messages-out': '0',
[BACK] [LAMBDA]         'x-faunadb-build': '2.6.4.rc4-3fa8865',
[BACK] [LAMBDA]         'x-faunadb-host': 'ec2-35-173-239-41.compute-1.amazonaws.com',
[BACK] [LAMBDA]         'x-points-network-out': '0.0',
[BACK] [LAMBDA]         'x-points-storage-read': '0.0',
[BACK] [LAMBDA]         'x-points-storage-write': '0.0',
[BACK] [LAMBDA]         'x-points-total': '0.0',
[BACK] [LAMBDA]         'x-query-bytes-in': '129',
[BACK] [LAMBDA]         'x-query-bytes-out': '209',
[BACK] [LAMBDA]         'x-query-time': '0',
[BACK] [LAMBDA]         'x-read-ops': '0',
[BACK] [LAMBDA]         'x-storage-bytes-read': '0',
[BACK] [LAMBDA]         'x-storage-bytes-write': '0',
[BACK] [LAMBDA]         'x-storage-ops-delete': '0',
[BACK] [LAMBDA]         'x-storage-ops-read': '0',
[BACK] [LAMBDA]         'x-storage-ops-write': '0',
[BACK] [LAMBDA]         'x-txn-delay': '0',
[BACK] [LAMBDA]         'x-txn-retries': '0',
[BACK] [LAMBDA]         'x-txn-time': '1559144535321508',
[BACK] [LAMBDA]         'x-write-ops': '0',
[BACK] [LAMBDA]         'content-length': '209',
[BACK] [LAMBDA]         connection: 'Close' },
[BACK] [LAMBDA]      startTime: 1559144535024,
[BACK] [LAMBDA]      endTime: 1559144535439 } }
[BACK] [LAMBDA] Response with status 400 in 417 ms.
[BACK] [LAMBDA] (node:10193) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'statusCode' of undefined
[BACK] [LAMBDA]     at callback (/home/mathieu/Bureau/acrabadabra/Acrabadabra/node_modules/netlify-lambda/lib/serve.js:35:42)
[BACK] [LAMBDA]     at /home/mathieu/Bureau/acrabadabra/Acrabadabra/node_modules/netlify-lambda/lib/serve.js:67:7
[BACK] [LAMBDA]     at tryCatch (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1803:12)
[BACK] [LAMBDA]     at invokeCallback (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1818:13)
[BACK] [LAMBDA]     at publish (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1792:7)
[BACK] [LAMBDA]     at flush (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1522:5)
[BACK] [LAMBDA]     at process._tickCallback (internal/process/next_tick.js:61:11)
[BACK] [LAMBDA] (node:10193) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
Request from::ffff:127.0.0.1:POST/todos create
[返回][LAMBDA]>
[BACK][LAMBDA]函数`todo create`调用了{“title”:“我早餐吃了什么…”,“completed”:true}
[返回][LAMBDA]错误{[BadRequest:验证失败]
[返回][LAMBDA]名称:'BadRequest',
[返回][LAMBDA]消息:“验证失败”,
[返回][LAMBDA]请求结果:
[返回][LAMBDA]请求结果{
[返回][LAMBDA]客户:
[返回][LAMBDA]客户端{
[返回][LAMBDA]_baseUrl:'https://db.fauna.com:443',
[返回][LAMBDA]\u超时:60000,
[返回][LAMBDA](秘密:'*****************************'
[返回][LAMBDA]\u观察员:null,
[返回][LAMBDA](上次查看:1559144535321508),
[BACK][LAMBDA]方法:“POST”,
[返回][LAMBDA]路径:“”,
[返回][LAMBDA]查询:null,
[BACK][LAMBDA]requestRaw:未定义,
[BACK][LAMBDA]requestContent:Expr{raw:[Object]},
[返回][LAMBDA]答复:
[BACK][LAMBDA]{“errors”:[{“position”:[],“code”:“validation failed”,“description”:“Instance data is not valid”,“failures”:[{“field”:[“data”],“code”:“invalid type”,“description”:“invalid type String,expected type Map.”}]}],
[返回][LAMBDA]响应内容:{errors:[Array]},
[返回][LAMBDA]状态代码:400,
[返回][LAMBDA]负责人:
[返回][LAMBDA]{'content type':'application/json;charset=utf-8',
[返回][LAMBDA]日期:“2019年5月29日星期三15:42:15 GMT”,
[返回][LAMBDA]“x-bus-bytes-in”:“0”,
[返回][LAMBDA]“x-bus-bytes-out”:“0”,
[返回][LAMBDA]“x-bus-messages-in”:“0”,
[返回][LAMBDA]“x-bus-messages-out”:“0”,
[返回][LAMBDA]“x-faunadb-build”:“2.6.4.rc4-3fa8865”,
[返回][LAMBDA]“x-faunadb-host”:“ec2-35-173-239-41.compute-1.amazonaws.com”,
[返回][LAMBDA]“x点网络输出”:“0.0”,
[返回][LAMBDA]“x点存储读取”:“0.0”,
[返回][LAMBDA]“x点存储写入”:“0.0”,
[返回][LAMBDA]“x点总数”:“0.0”,
[返回][LAMBDA]“x-query-bytes-in”:“129”,
[返回][LAMBDA]“x-query-bytes-out”:“209”,
[返回][LAMBDA]“x查询时间”:“0”,
[返回][LAMBDA]“x-read-ops”:“0”,
[返回][LAMBDA]“x-storage-bytes-read”:“0”,
[返回][LAMBDA]“x-storage-bytes-write”:“0”,
[返回][LAMBDA]“x-storage-ops-delete”:“0”,
[返回][LAMBDA]“x-storage-ops-read”:“0”,
[返回][LAMBDA]“x-storage-ops-write”:“0”,
[返回][LAMBDA]“x-txn-delay”:“0”,
[返回][LAMBDA]“x-txn-retries”:“0”,
[返回][LAMBDA]“x-txn-time”:“1559144535321508”,
[返回][LAMBDA]“x-write-ops”:“0”,
[返回][LAMBDA]“内容长度”:“209”,
[返回][LAMBDA]连接:'关闭'},
[返回][LAMBDA]起始时间:1559144535024,
[返回][LAMBDA]结束时间:1559144535439}
[返回][LAMBDA]417毫秒内状态为400的响应。
[返回][LAMBDA](节点:10193)未经处理的PromisejectionWarning:TypeError:无法读取未定义的属性“statusCode”
回调时的[BACK][LAMBDA](/home/mathieu/Bureau/acrabadabra/acrabadabra/node_modules/netlify LAMBDA/lib/service.js:35:42)
[返回][LAMBDA]at/home/mathieu/Bureau/acrabadabra/acrabadabra/node_modules/netlify LAMBDA/lib/service.js:67:7
[返回][LAMBDA]在tryCatch(/home/mathieu/Bureau/acrabadabra/acrabadabra/functions/todos create.js:1803:12)
[BACK][LAMBDA]位于invokeCallback(/home/mathieu/Bureau/acrabadabra/acrabadabra/functions/todos create.js:1818:13)
[返回][LAMBDA]发布时(/home/mathieu/Bureau/acrabadabra/acrabadabra/functions/todos create.js:1792:7)
[BACK][LAMBDA]处于齐平状态(/home/mathieu/Bureau/acrabadabra/acrabadabra/functions/todos create.js:1522:5)
[返回][LAMBDA]在进程中。_tickCallback(内部/process/next_tick.js:61:11)
[返回][LAMBDA](节点:10193)未处理的PromisejectionWarning:未处理的承诺拒绝。此错误源于在没有catch块的异步函数中抛出,或者拒绝未使用.catch()处理的承诺。(拒绝id:4)
GET请求是功能性的,我试过了。
您知道这个问题吗?

删除stringify更改nothing,我在lambda函数中添加了控制台日志以了解更多详细信息:

/* code from functions/todos-create.js */
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 */
  console.log('<<<<<<<<<' + "      " + event.body + "       " + '>>>>>>>>>')
  const eventBody = JSON.stringify(event.body)
  console.log('<<<<<<<<<' + "      " + eventBody + "       " + '>>>>>>>>>')
  const data = JSON.parse(eventBody)
  console.log('<<<<<<<<<' + "      " + data + "       " + '>>>>>>>>>')
  console.log("Function `todo-create` invoked", data)
  const todoItem = {
    data: data
  }
  // {"title":"What I had for breakfast ..","completed":true}
  console.log('<<<<<<<<<' + "      " + todoItem + "       " + '>>>>>>>>>')
  /* construct the fauna query */
  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)
    })
  })
}

在我的解决方案中,在请求的参数变量中添加第二个JSON解析:

const todoItem = {
    data: JSON.parse(data)
  }
根据错误中的描述(“无效类型字符串,预期类型映射”),可以从获取正文中删除stringify
[BACK] [LAMBDA] Request from ::ffff:127.0.0.1: POST /todos-create
[BACK] [LAMBDA] <<<<<<<<<      [object Object]       >>>>>>>>>
[BACK] [LAMBDA] <<<<<<<<<      "[object Object]"       >>>>>>>>>
[BACK] [LAMBDA] <<<<<<<<<      [object Object]       >>>>>>>>>
[BACK] [LAMBDA] Function `todo-create` invoked [object Object]
[BACK] [LAMBDA] error { [BadRequest: validation failed]
[BACK] [LAMBDA]   name: 'BadRequest',
[BACK] [LAMBDA]   message: 'validation failed',
[BACK] [LAMBDA]   requestResult:
[BACK] [LAMBDA]    RequestResult {
[BACK] [LAMBDA]      client:
[BACK] [LAMBDA]       Client {
[BACK] [LAMBDA]         _baseUrl: 'https://db.fauna.com:443',
[BACK] [LAMBDA]         _timeout: 60000,
[BACK] [LAMBDA]         _secret: '*************************',
[BACK] [LAMBDA]         _observer: null,
[BACK] [LAMBDA]         _lastSeen: 1559289243066157 },
[BACK] [LAMBDA]      method: 'POST',
[BACK] [LAMBDA]      path: '',
[BACK] [LAMBDA]      query: null,
[BACK] [LAMBDA]      requestRaw: undefined,
[BACK] [LAMBDA]      requestContent: Expr { raw: [Object] },
[BACK] [LAMBDA]      responseRaw:
[BACK] [LAMBDA]       '{"errors":[{"position":[],"code":"validation failed","description":"Instance data is not valid.","failures":[{"field":["data"],"code":"invalid type","description":"Invalid type String, expected type Map."}]}]}',
[BACK] [LAMBDA]      responseContent: { errors: [Array] },
[BACK] [LAMBDA]      statusCode: 400,
[BACK] [LAMBDA]      responseHeaders:
[BACK] [LAMBDA]       { 'content-type': 'application/json;charset=utf-8',
[BACK] [LAMBDA]         date: 'Fri, 31 May 2019 07:54:03 GMT',
[BACK] [LAMBDA]         'x-bus-bytes-in': '0',
[BACK] [LAMBDA]         'x-bus-bytes-out': '0',
[BACK] [LAMBDA]         'x-bus-messages-in': '0',
[BACK] [LAMBDA]         'x-bus-messages-out': '0',
[BACK] [LAMBDA]         'x-faunadb-build': '2.6.4.rc4-3fa8865',
[BACK] [LAMBDA]         'x-faunadb-host': 'ec2-35-173-239-41.compute-1.amazonaws.com',
[BACK] [LAMBDA]         'x-points-network-out': '0.0',
[BACK] [LAMBDA]         'x-points-storage-read': '0.0',
[BACK] [LAMBDA]         'x-points-storage-write': '0.0',
[BACK] [LAMBDA]         'x-points-total': '0.0',
[BACK] [LAMBDA]         'x-query-bytes-in': '82',
[BACK] [LAMBDA]         'x-query-bytes-out': '209',
[BACK] [LAMBDA]         'x-query-time': '3',
[BACK] [LAMBDA]         'x-read-ops': '0',
[BACK] [LAMBDA]         'x-storage-bytes-read': '0',
[BACK] [LAMBDA]         'x-storage-bytes-write': '0',
[BACK] [LAMBDA]         'x-storage-ops-delete': '0',
[BACK] [LAMBDA]         'x-storage-ops-read': '0',
[BACK] [LAMBDA]         'x-storage-ops-write': '0',
[BACK] [LAMBDA]         'x-txn-delay': '0',
[BACK] [LAMBDA]         'x-txn-retries': '0',
[BACK] [LAMBDA]         'x-txn-time': '1559289243066157',
[BACK] [LAMBDA]         'x-write-ops': '0',
[BACK] [LAMBDA]         'content-length': '209',
[BACK] [LAMBDA]         connection: 'Close' },
[BACK] [LAMBDA]      startTime: 1559289242318,
[BACK] [LAMBDA]      endTime: 1559289243199 } }
[BACK] [LAMBDA] Response with status 400 in 883 ms.
[BACK] [LAMBDA] (node:5201) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'statusCode' of undefined
[BACK] [LAMBDA]     at callback (/home/mathieu/Bureau/acrabadabra/Acrabadabra/node_modules/netlify-lambda/lib/serve.js:35:42)
[BACK] [LAMBDA]     at /home/mathieu/Bureau/acrabadabra/Acrabadabra/node_modules/netlify-lambda/lib/serve.js:67:7
[BACK] [LAMBDA]     at tryCatch (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1803:12)
[BACK] [LAMBDA]     at invokeCallback (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1818:13)
[BACK] [LAMBDA]     at publish (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1792:7)
[BACK] [LAMBDA]     at flush (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1522:5)
[BACK] [LAMBDA]     at process._tickCallback (internal/process/next_tick.js:61:11)
[BACK] [LAMBDA] (node:5201) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 7)
[BACK] [LAMBDA] Request from ::ffff:127.0.0.1: POST /todos-create
[BACK] [LAMBDA] <<<<<<<<<      {"title":"What I had for breakfast ..","completed":true}       >>>>>>>>>
[BACK] [LAMBDA] <<<<<<<<<      "{\"title\":\"What I had for breakfast ..\",\"completed\":true}"       >>>>>>>>>
[BACK] [LAMBDA] <<<<<<<<<      {"title":"What I had for breakfast ..","completed":true}       >>>>>>>>>
[BACK] [LAMBDA] Function `todo-create` invoked {"title":"What I had for breakfast ..","completed":true}
[BACK] [LAMBDA] <<<<<<<<<      [object Object]       >>>>>>>>>
[BACK] [LAMBDA] (node:11199) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[BACK] [LAMBDA] error { [BadRequest: validation failed]
[BACK] [LAMBDA]   name: 'BadRequest',
[BACK] [LAMBDA]   message: 'validation failed',
[BACK] [LAMBDA]   requestResult:
[BACK] [LAMBDA]    RequestResult {
[BACK] [LAMBDA]      client:
[BACK] [LAMBDA]       Client {
[BACK] [LAMBDA]         _baseUrl: 'https://db.fauna.com:443',
[BACK] [LAMBDA]         _timeout: 60000,
[BACK] [LAMBDA]         _secret: '****************************',
[BACK] [LAMBDA]         _observer: null,
[BACK] [LAMBDA]         _lastSeen: 1559294662744534 },
[BACK] [LAMBDA]      method: 'POST',
[BACK] [LAMBDA]      path: '',
[BACK] [LAMBDA]      query: null,
[BACK] [LAMBDA]      requestRaw: undefined,
[BACK] [LAMBDA]      requestContent: Expr { raw: [Object] },
[BACK] [LAMBDA]      responseRaw:
[BACK] [LAMBDA]       '{"errors":[{"position":[],"code":"validation failed","description":"Instance data is not valid.","failures":[{"field":["data"],"code":"invalid type","description":"Invalid type String, expected type Map."}]}]}',
[BACK] [LAMBDA]      responseContent: { errors: [Array] },
[BACK] [LAMBDA]      statusCode: 400,
[BACK] [LAMBDA]      responseHeaders:
[BACK] [LAMBDA]       { 'content-type': 'application/json;charset=utf-8',
[BACK] [LAMBDA]         date: 'Fri, 31 May 2019 09:24:22 GMT',
[BACK] [LAMBDA]         'x-bus-bytes-in': '0',
[BACK] [LAMBDA]         'x-bus-bytes-out': '0',
[BACK] [LAMBDA]         'x-bus-messages-in': '0',
[BACK] [LAMBDA]         'x-bus-messages-out': '0',
[BACK] [LAMBDA]         'x-faunadb-build': '2.6.4.rc4-3fa8865',
[BACK] [LAMBDA]         'x-faunadb-host': 'ec2-35-173-239-41.compute-1.amazonaws.com',
[BACK] [LAMBDA]         'x-points-network-out': '0.0',
[BACK] [LAMBDA]         'x-points-storage-read': '0.0',
[BACK] [LAMBDA]         'x-points-storage-write': '0.0',
[BACK] [LAMBDA]         'x-points-total': '0.0',
[BACK] [LAMBDA]         'x-query-bytes-in': '129',
[BACK] [LAMBDA]         'x-query-bytes-out': '209',
[BACK] [LAMBDA]         'x-query-time': '0',
[BACK] [LAMBDA]         'x-read-ops': '0',
[BACK] [LAMBDA]         'x-storage-bytes-read': '0',
[BACK] [LAMBDA]         'x-storage-bytes-write': '0',
[BACK] [LAMBDA]         'x-storage-ops-delete': '0',
[BACK] [LAMBDA]         'x-storage-ops-read': '0',
[BACK] [LAMBDA]         'x-storage-ops-write': '0',
[BACK] [LAMBDA]         'x-txn-delay': '0',
[BACK] [LAMBDA]         'x-txn-retries': '0',
[BACK] [LAMBDA]         'x-txn-time': '1559294662744534',
[BACK] [LAMBDA]         'x-write-ops': '0',
[BACK] [LAMBDA]         'content-length': '209',
[BACK] [LAMBDA]         connection: 'Close' },
[BACK] [LAMBDA]      startTime: 1559294662390,
[BACK] [LAMBDA]      endTime: 1559294663102 } }
[BACK] [LAMBDA] Response with status 400 in 762 ms.
[BACK] [LAMBDA] (node:11199) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'statusCode' of undefined
[BACK] [LAMBDA]     at callback (/home/mathieu/Bureau/acrabadabra/Acrabadabra/node_modules/netlify-lambda/lib/serve.js:35:42)
[BACK] [LAMBDA]     at /home/mathieu/Bureau/acrabadabra/Acrabadabra/node_modules/netlify-lambda/lib/serve.js:67:7
[BACK] [LAMBDA]     at tryCatch (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1803:12)
[BACK] [LAMBDA]     at invokeCallback (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1818:13)
[BACK] [LAMBDA]     at publish (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1792:7)
[BACK] [LAMBDA]     at flush (/home/mathieu/Bureau/acrabadabra/Acrabadabra/functions/todos-create.js:1522:5)
[BACK] [LAMBDA]     at process._tickCallback (internal/process/next_tick.js:61:11)
[BACK] [LAMBDA] (node:11199) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
[BACK] [LAMBDA] (node:11199) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
const todoItem = {
    data: {"title":"What I had for breakfast ..","completed":true}
  }
const todoItem = {
    data: JSON.parse(data)
  }