minapp-fetch
Version:
46 lines (45 loc) • 1.85 kB
JavaScript
;
/*
* @Author: your name
* @Date: 2020-04-16 19:21:06
* @LastEditTime: 2020-04-16 20:07:47
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /minapp-fetch/src/fetch/content/deleteCategory.ts
*/
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./utils/utils");
const constants_1 = require("./constants/constants");
const error_1 = require("./constants/error");
function fetchDeleteCategory(contentGroupID, categoryID) {
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.delete(categoryID).then((res) => {
// success
resolve(res);
}, (err) => {
// err
reject(err);
});
}
}
//op 运营后台
if (minapp === constants_1.PLATFORM_NAME.ZX_OP) {
BaaS_F.delete(`https://cloud.minapp.com/userve/v2.2/content/${contentGroupID}/category/${categoryID}/`).then((res) => {
resolve(res);
}).catch((err) => {
reject(err);
});
}
if (constants_1.PLATFORM_NAME_MONGO_SERVER.indexOf(minapp) > -1) {
throw new Error(`minapp.deleteCategory ${error_1.METHOD_NOT_SUPPORT}`);
}
if (constants_1.PLATFORM_ALL.indexOf(minapp) === -1) {
throw new Error(`minapp.deleteCategory ${error_1.METHOD_NOT_SUPPORT}`);
}
});
}
exports.default = fetchDeleteCategory;