0

嘿,我怎样才能得到参数数据?

// this is serverless.yml
test_function:
    handler: handler.test
    events:
    - http:
        path: "registry/{some_data}"
        method: get
        request:
          template:
            application/json: >
              {
                "damn": "$input.params('some_data')"
              }

// this is handle.js
module.exports.test= (event, context, cb) => {
  cb(null, { bangke: 'Dorrrrr !!'+event.some_data});
};

但是 event.some_data print undefine 有人知道代码有什么问题吗?

4

1 回答 1

0

如果我理解正确,您正在尝试传递路径参数。在这种情况下,请使用以下内容:

serverless.yml

test_function:
  handler: handler.test
  events:
    - http:
        path: registry/{some_data}
        method: get

handler.js

module.exports.test= (event, context, cb) => {
  cb(null, { bangke: 'Dorrrrr !!'+ event.path.some_data});
};
于 2016-10-10T13:11:04.797 回答