大家好,我已经在 IBM 云上部署了一个函数,我通过 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
}
}