本文整理匯總了TypeScript中@angular/common/http.HttpClient.put方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript HttpClient.put方法的具體用法?TypeScript HttpClient.put怎麽用?TypeScript HttpClient.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/common/http.HttpClient
的用法示例。
在下文中一共展示了HttpClient.put方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: updateLocales
updateLocales(map: Map<String, String>, lang) {
let body = '{';
if (map) {
map.forEach((value: string, key: string) => {
body += '"' + key + '":' + '"' + value + '",';
});
}
body = body.slice(0, -1);
body += '}';
return this.http.put(httpApiHost + '/locales/' + lang, body, httpJsonOptions);
}
示例2: getCollectionPath
update<T extends Identifiable>(kind: ResourceType<T>, item: T): Observable<T> {
const collectionPath = getCollectionPath(kind.typeId);
const uri = `${API_BASE_URL}/${collectionPath}/${item.id}`;
return this.http
.put<T>(uri, item)
.pipe(
tap(entity => this.logger.log(`Updated ${kind.typeId}: ${JSON.stringify(entity)}.`)),
retryAfter(2, 1000),
catchError(this.handleError),
);
}
示例3: updateVoucher
updateVoucher(){
var id = 1002;
var url = "/api/vouchers/" + id;
var vtu = { "ID": id, "Text": "Updated by Angular", "Date": "2016-04-22T16:59:32.086", "Amount": 99, "Paid": true, "Expense": false, "VATRate" : 20 };
this.httpClient.put('http://localhost:5000/api/vouchers', vtu)
.toPromise()
.then((response)=>{
console.log('voucher updated');
this.result = response;})
}
示例4: updateApi
public updateApi(
api: Api,
namespace: string,
token: string,
): Observable<Api> {
const httpOptions = this.getHTTPOptions(token);
const url = `${AppConfig.apisApiUrl}/namespaces/${namespace}/apis/${
api.metadata.name
}`;
return this.http.put<Api>(url, api, httpOptions);
}
示例5: manageUser
/**
* Manage an existing user or create a new one.
*
* @param {User} user
* @param operation whether we're creating a new user or updating an existing one
*/
manageUser(user: User, operation: UserOperations = UserOperations.CREATE): Observable<any> {
let url = '/api/users';
if (operation === UserOperations.UPDATE) {
url += `/${user.username}`;
}
return this.http
.put(url, user)
.pipe(map(r => plainToClass(ApiResponse, r)));
}
示例6: save_changes_to_comic
save_changes_to_comic(comic: Comic, series: string, volume: string, issue_number: string): Observable<any> {
const params = new HttpParams()
.set('series', series)
.set('volume', volume)
.set('issue_number', issue_number);
return this.http.put(`${COMIC_SERVICE_API_URL}/comics/${comic.id}`, params)
.finally(() => {
comic.series = series;
comic.volume = volume;
comic.issue_number = issue_number;
});
}
示例7: tap
update<T extends Identifiable>(kind: Type<T>, item: T): Observable<T> {
const uri = `${BASE_API_URI}${API_ENDPOINTS[kind.name]}/${item.id}`;
return this.http
.put<CustomResponse<T>>(uri, item)
.pipe(
tap(entity => this.logger.log(`Response: ${JSON.stringify(entity)}.`)),
map(productResponse => productResponse.data),
tap(entity => this.logger.log(`Updated: ${JSON.stringify(entity)}.`)),
retryAfter(3, 1000),
catchError(this.handleError),
);
}
示例8: updateOrder
/**
*
*
* @param {any} params
* @returns
*
* @memberof CheckoutService
*/
updateOrder(params: any) {
const url = `api/v1/checkouts/${
this.orderNumber
}.json?order_token=${this.getOrderToken()}`;
return this.http
.put<Order>(url, params)
.pipe(
map(order =>
this.store.dispatch(this.actions.updateOrderSuccess(order))
)
);
}
示例9: changeOrderState
/**
*
*
* @returns
*
* @memberof CheckoutService
*/
changeOrderState() {
const url = `api/v1/checkouts/${
this.orderNumber
}/next.json?order_token=${this.getOrderToken()}`;
return this.http
.put<Order>(url, {})
.pipe(
map(order =>
this.store.dispatch(this.actions.changeOrderStateSuccess(order))
)
);
}
示例10: respondToMessage
/**
* Responds to a message by calling a trigger endpoint for a given workflow's execution ID.
* @param workflow_execution_id Execution ID of workflow to trigger
* @param action Action to send to trigger endpoint
*/
respondToMessage(workflow_execution_id: string, action: string): Promise<string[]> {
const arg = new Argument();
arg.name = 'action';
arg.value = action;
const body: object = {
execution_ids: [workflow_execution_id],
data_in: action,
arguments: [arg],
};
return this.http.put('/api/triggers/send_data', body)
.toPromise()
.catch(this.utils.handleResponseError);
}