本文整理汇总了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();
}),);
}