From e64f9e62d94261a030a15a9ecc0ae4686381ed38 Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Fri, 19 Aug 2022 17:22:52 +0800 Subject: [PATCH] docs: get uniCloud requestId --- docs/uniCloud/cf-callfunction.md | 1 + docs/uniCloud/cloud-obj.md | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/docs/uniCloud/cf-callfunction.md b/docs/uniCloud/cf-callfunction.md index ba8ab02d5..093b42189 100644 --- a/docs/uniCloud/cf-callfunction.md +++ b/docs/uniCloud/cf-callfunction.md @@ -128,6 +128,7 @@ context对象的属性清单如下: |CLIENTIP |string |客户端IP。如果调用来源是其他服务器,会返回调用方的ip | |CLIENTUA |string |客户端userAgent。注意非本地运行环境下客户端getSystemInfoSync也会获取ua参数并上传给云函数,但是云函数会从http请求头里面获取ua而不是clientInfo里面的ua | |uniIdToken |string |客户端uni-id token字符串,新增于HBuilderX 3.5.1。 | +|requestId |string |当前请求id,新增于HBuilderX 3.5.5。 | 除了上述属性,如果是uni-app客户端通过callfunction访问云函数,那么context还会追加一批客户端信息。 - HBuilderX 3.4.9前,context 添加了一批大写属性,如APPID、OS。 diff --git a/docs/uniCloud/cloud-obj.md b/docs/uniCloud/cloud-obj.md index d075fff6f..1b996ce6e 100644 --- a/docs/uniCloud/cloud-obj.md +++ b/docs/uniCloud/cloud-obj.md @@ -385,6 +385,25 @@ module.exports = { } ``` +### 获取当前请求id@get-request-id + +**接口形式** + +`this.getUniCloudRequestId()` + +**示例** + +```js +module.exports = { + _after: function(error, result) { + if(error) { + const requestId = this.getUniCloudRequestId() + // log(requestId, error) 出错时记录日志,log方法需自行实现 + } + } +} +``` + ### 获取url化时的http信息@get-http-info > 新增于HBuilderX 3.5.2 -- GitLab