本文整理匯總了TypeScript中dotcms-js.ApiRoot類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ApiRoot類的具體用法?TypeScript ApiRoot怎麽用?TypeScript ApiRoot使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ApiRoot類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: remove
remove(model: ConditionModel): Observable<ConditionModel> {
const opts = this._apiRoot.getDefaultRequestOptions();
const remove = this._http
.delete(this._baseUrl + '/' + model.key, opts).pipe(
map((_res: Response) => {
return model;
}));
return remove.pipe(catchError(this._catchRequestError('remove')));
}
示例2: Error
add(groupId: string, model: ConditionModel): Observable<any> {
// this.loggerService.info("api.rule-engine.ConditionService", "add", model)
if (!model.isValid()) {
throw new Error(`This should be thrown from a checkValid function on the model,
and should provide the info needed to make the user aware of the fix.`);
}
const json = ConditionService.toJson(model);
json.owningGroup = groupId;
const opts = this._apiRoot.getDefaultRequestOptions();
const add = this._http
.post(this._baseUrl + '/', JSON.stringify(json), opts).pipe(
map((res: Response) => {
const json = res.json();
model.key = json.id;
return model;
}));
return add.pipe(catchError(this._catchRequestError('add')));
}
示例3: observableEmpty
makeRequest(childPath: string): Observable<any> {
const opts = this._apiRoot.getDefaultRequestOptions();
return this._http
.get(this._baseUrl + '/' + childPath, opts).pipe(
map((res: Response) => {
return res.json();
}),
catchError((err: any, _source: Observable<any>) => {
if (err && err.status === HttpCode.NOT_FOUND) {
this.loggerService.info('Could not retrieve Condition Types: URL not valid.');
} else if (err) {
this.loggerService.info(
'Could not retrieve Condition Types.',
'response status code: ',
err.status,
'error:',
err
);
}
return observableEmpty();
}),);
}