本文整理汇总了TypeScript中dotcms-js.ApiRoot.getDefaultRequestOptions方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ApiRoot.getDefaultRequestOptions方法的具体用法?TypeScript ApiRoot.getDefaultRequestOptions怎么用?TypeScript ApiRoot.getDefaultRequestOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dotcms-js.ApiRoot
的用法示例。
在下文中一共展示了ApiRoot.getDefaultRequestOptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: add
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: save
save(groupId: string, model: ConditionModel): Observable<ConditionModel> {
this.loggerService.info('api.rule-engine.ConditionService', 'save', 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.`);
}
if (!model.isPersisted()) {
this.add(groupId, model);
} else {
const json = ConditionService.toJson(model);
json.owningGroup = groupId;
const opts = this._apiRoot.getDefaultRequestOptions();
const body = JSON.stringify(json);
const save = this._http
.put(this._baseUrl + '/' + model.key, body, opts).pipe(
map((_res: Response) => {
return model;
}));
return save.pipe(catchError(this._catchRequestError('save')));
}
}
示例4: makeRequest
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();
}),);
}