Skip to content

Commit

Permalink
doc: add cloud sdk attribute introduction(#1572)
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwhite committed Oct 11, 2023
1 parent c8f8ccc commit 9c1550e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/guide/function/function-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ title: 云函数 SDK
import cloud from "@lafjs/cloud";
```

## SDK 属性

`cloud` 具有下面的一些参数:

| 属性 | 介绍 |
| --------------- | ----------------------------------------------------------------------------------- |
| `cloud.appid` | 当前 Laf 应用的 appid |
| `cloud.database()` | 当前应用的数据库对象 |
| `cloud.env` | 当前应用的环境变量,也可用 `process.env` |
| `cloud.fetch` | 可在云函数中发起 HTTP 请求,基于`axios`封装 |
| `cloud.getToken` | 生成 JWT Token |
| `cloud.parseToken` | 解密 JWT Token |
| `cloud.invoke` | 请求其他云函数 |
| `cloud.shared` | 当前应用的全局缓存 |
| `cloud.mongo` | 当前应用的原生 MongoDB 实例 |
| `cloud.sockets` | 当前应用的socket实例|

## 发送网络请求

使用 `cloud.fetch()` 可发起 HTTP 请求,调用三方接口,可完成如支付接口、短信验证码等等三方接口操作。
Expand Down

0 comments on commit 9c1550e

Please sign in to comment.