IBM Openwhisk,无法提取路由参数

时间:2019-02-26 16:35:40

标签: node.js serverless openwhisk ibm-cloud-functions

大家好,我已经在IBM Cloud上部署了一个函数,我通过Web api对其进行了调用,但是除了涉及路由参数的那些函数(我无法提取它们)之外,所有函数都可以正常工作。我正在使用无服务器框架,并且在调用变量__ow_path时返回空。任何帮助将不胜感激。谢谢。

serverless.yml文件:

getById:
  handler: handler.getById
  overwrite: true
  annotations:
    web-export: true
  events:
    - http: 
        method: GET
        path: /users/{userid}
        resp: http

handler.js文件:

module.exports.getById = async (params) => {
    return {
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
            params,
            msg: params.__ow_path,
            created: new Date()
        }),
        statusCode: 200
    }
}

1 个答案:

答案 0 :(得分:1)

请将[['a', 'b', 'c'], 2] 软件包升级到版本0.18.3。这是由于0.18中引入了known bug

以上示例是有效的。