UNPKG

minapp-fetch

Version:
47 lines (46 loc) 1.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /* * @Author: your name * @Date: 2020-04-16 19:19:57 * @LastEditTime: 2020-04-16 19:49:42 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: /minapp-fetch/src/fetch/content/setCategory.ts */ const utils_1 = require("./utils/utils"); const constants_1 = require("./constants/constants"); const error_1 = require("./constants/error"); function fetchSetCategory(contentGroupID, params) { let { BaaS_F, minapp } = utils_1.getBaaSF(); return new Promise((resolve, reject) => { if (constants_1.PLATFORM_NAME_BAAS.indexOf(minapp) > -1) { if (minapp === constants_1.PLATFORM_NAME.ZX_CLOUD) { let MyContentCategory = new BaaS_F.ContentCategory(contentGroupID); MyContentCategory.create(params).then((res) => { // success resolve(res); }, (err) => { // err reject(err); }); } } //MongoDB if (constants_1.PLATFORM_NAME_MONGO_SERVER.indexOf(minapp) > -1) { throw new Error(`minapp.setCategory ${error_1.METHOD_NOT_SUPPORT}`); } //op 运营后台 if (minapp === constants_1.PLATFORM_NAME.ZX_OP) { BaaS_F.post(`https://cloud.minapp.com/userve/v2.2/content/${contentGroupID}/category/`, params).then((res) => { resolve(res); }).catch((err) => { reject(err); }); } if (constants_1.PLATFORM_ALL.indexOf(minapp) === -1) { throw new Error(`minapp.setCategory ${error_1.METHOD_NOT_SUPPORT}`); } }); } exports.default = fetchSetCategory;