const getEntityByCustCode = async(keys, service) => {
return await service.run({
url: keys,
method: 'GET',
headers: {
Accept: 'application/json',
},
});
};
const getEntityAllByCustCode = async(org, importData, service) => {
var hasError = false;
var entityData = {
d: {
results: []
}
};
//Get Division
var getDivision = getEntityByCustCode(
getQueryFilterUrl(org.companyOrgCode, '3'), service
);
//Get Department
var getDepartment = getEntityByCustCode(
getQueryFilterUrl(org.companyOrgCode, '4'), service
);
//Get Section
var getSection = getEntityByCustCode(
getQueryFilterUrl(org.companyOrgCode, '5'), service
);
//Get Unit
var getUnit = getEntityByCustCode(
getQueryFilterUrl(org.companyOrgCode, '6'), service
);
// Error happens in here //
var [entityDataDiv, entityDataDep, entityDataSec, entityDataUni] = await Promise.all([
getDivision, getDepartment, getSection, getUnit
]).catch((error) => {
org.Status = 'E';
org.Message = error.message;
hasError = true;
});
if (hasError) {
return false;
}
entityData.d.results = entityData.d.results.concat(entityDataDiv.d.results);
entityData.d.results = entityData.d.results.concat(entityDataDep.d.results);
entityData.d.results = entityData.d.results.concat(entityDataSec.d.results);
entityData.d.results = entityData.d.results.concat(entityDataUni.d.results);
return entityData;
};
在 react-native 中为 ios 运行此代码获取 TypeError:无法读取未定义的属性 'init'
答案 0 :(得分:0)
import Couchbase from "react-native-couchbase-lite";
Couchbase.initRESTClient(manager => {
// use manager to perform operations
});
似乎不仅有 init 方法,您还应该使用其他 init 方法。
请注意,iOS 还需要采取一些特殊步骤。