index.obj.js 1.0 KB
Newer Older
1 2 3 4 5 6
// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程:https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
module.exports = {
  async add(title, content) {
    console.log(title, content)
    return {
雪洛's avatar
雪洛 已提交
7 8
      title,
      content,
9 10 11 12 13 14 15 16 17
      showMessage: `Todo added, title: ${title}, content: ${content}`
    }
  },
  async randomFail() {
    const random = Math.random()
    console.log(random);
    if (random > 0.5) {
      return {
        errCode: 'RANDOM_FAIL',
雪洛's avatar
雪洛 已提交
18
        errMsg: '[预期内的报错]执行失败请重试'
19 20 21 22 23
      }
    } else {
      return {
        errCode: 0,
        errMsg: '',
雪洛's avatar
雪洛 已提交
24
        showMessage: '执行成功'
25 26 27 28 29 30
      }
    }
  },
  async fail() {
    return {
      errCode: 'TEST_ERROR_CODE',
雪洛's avatar
雪洛 已提交
31
      errMsg: '[预期内的报错]执行失败',
32 33
    }
  },
34 35 36 37 38 39
  async failWithNumberErrCode() {
    return {
      errCode: -1,
      errMsg: '[预期内的报错]执行失败',
    }
  },
40 41 42 43
  async success() {
    return {
      errCode: 0,
      errMsg: '',
雪洛's avatar
雪洛 已提交
44
      showMessage: '执行成功'
45 46 47
    }
  }
}