# 执行云函数
# 简要描述
- 执行云端js函数,支持内置函数
# 请求URL
/api/execFunction
# 请求头
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| Content-Type | 是 | string | 此参数必传,当请求数据非json时此参数传对应格式如(multipartform-data,application/x-www-form-urlencoded,等)是json请传application/json |
| askKey | 是 | string | 此参数必传,验证app的令牌 |
| sign | 否 | string | 此参数如果在app设置开启了验签是必传 |
| time | 否 | string | 当开启验签时,此参数为必传 |
| apiUserToken | 否 | string | 用户令牌 |
| nonce | 否 | string | 随机字符串(当开启V3验签此参数必传,且6分钟内不允许重复) |
# 请求方式
- post
# 参数
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| name | 是 | string | 函数名称 |
| params | 否 | json | 参数名称 |
# 云函数实例
// 函数名称test11,下面是函数内容
function add(x, y) {
const sum = x + y
return sum // 返回sum
}
let result = add(1, 2)
result+name
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 请求示例
{
"name":"test11",
"params":{
"name":"土豆api"
}
}
1
2
3
4
5
6
2
3
4
5
6
# 返回示例
{
"code": "200",
"message": "",
"status": true,
"data": "3土豆api",
"pc": null,
"time": null,
"sign": null,
"sign": null
}
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
# 返回参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | string | 状态码200成功403权限异常或登录超时,500请求异常 |
| status | int | 状态0删除1使用 |
| data | object | 返回结果 |
| nonce | string | 随机字符串(当开启V3验签必返回次参数,且6分钟内不会重复) |
| sign | string | 此参数如果在app设置开启了验签是必返 |
| reqSign | string | 请求签名 |
| time | long | 当开启验签时,此参数为必返回 |
# 备注
云函数内置数据库方法与 HTTP 数据库接口参数一致,详见云函数文档:
| 名称 | 调用 | param 要点 |
|---|---|---|
| 查询一条 | potato.selectOne(table, param) | 字段平铺等值 |
| 查询多条 | potato.selectList(table, param) | where + pc |
| 添加一条 | potato.addOne(table, param) | 字段平铺 |
| 添加多条 | potato.addList(table, param) | { list: [...] } |
| 修改 | potato.updateOne(table, param) | column + where |
| 删除 | potato.deleteOne(table, param) | { where: {...} } |
| 查询用户信息 | potato.findCurrentUserInfo() | |
| 获取APP信息 | potato.getAppInfo() | |
| 验证卡密V1 | potato.verifyCardV1(param) | |
| 验证卡密V2 | potato.verifyCardV2(param) | |
| 用户注册V2 | potato.registerV2(param) | |
| 创建卡密 | potato.createCardMy(param) | |
| 余额购买会员 | potato.userByVipWithBalance(param) | |
| 公众号通知 | potato.sendWeChatMessage(param) |
请求头验签规则见 接口规范(V1 / V2 / V3)。
- 更多返回错误代码请查看 错误代码参考