Obviously in a real world application we do not only fetch data from the backend, but we also send data to be stored permanently on the server side. The HttpClient gives us different options for achieving this. In this lesson we will look at how to attach parameters to our request URL, by manually concatenating the URL by ourselves, by using the HttpParams object and also how we can send entire objects in a POSTrequest body.

import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http'; export interface Person {
name: string;
} @Injectable()
export class PeopleService { constructor(private http: HttpClient) {} fetchPeople(): Observable<Person> { // The same as /api/v1/people?id=2&includeName=false
const params = new HttpParams()
.set('id', '2')
.set('includeName', 'false'); return this.http
.get<Person>('/api/v1/people', {
params
});
} }

[Angular] Send Data via HTTP using Angular HttpParams的更多相关文章

  1. [Angular 2 Router] Configure Your First Angular 2 Route

    Using the Angular 2 router requires defining routes, passing them in to the RouterModule.forRoot and ...

  2. lr11 BUG?Failed to send data by channels - post message failed.

    问题描述   : http协议,场景运行一会之后,报错! erro信息: Failed to send data by channels - post message failed. 解决方法 :ht ...

  3. 【C#】Send data between applications

    This sample shows how to send data between different applications, including object data——transform ...

  4. 【Angular专题】——(1)Angular,孤傲的变革者

    目录 一. 漫谈Angular 二. 如果你还在使用Angularjs 三. 我计划这样学习Angular技术栈 一. 漫谈Angular Angular,来自Google的前端SPA框架,与Reac ...

  5. [Angular] Use Angular components in AngularJS applications with Angular Elements

    When migrating AngularJS (v1.x) applications to Angular you have different options. Using Angular El ...

  6. TCP requires two packet transfers to set up the connection before it can send data

    wHTTP重用现存连接来减少TCP建立时延. HTTP The Definitive Guide 4.2.3 TCP Connection Handshake Delays When you set ...

  7. Caused by java.lang.Exception Failed to send data to Kafka Expiring

    flink 写kafka,报错,作业挂掉 Caused by: java.lang.Exception: Failed to send data to Kafka: Expiring 89 recor ...

  8. Angular 从入坑到挖坑 - Angular 使用入门

    一.Overview angular 入坑记录的笔记第一篇,完成开发环境的搭建,以及如何通过 angular cli 来创建第一个 angular 应用.入坑一个多星期,通过学习官方文档以及手摸手的按 ...

  9. [从 0 开始的 Angular 生活]No.38 实现一个 Angular Router 切换组件页面(一)

    前言 今天是进入公司的第三天,为了能尽快投入项目与成为团队可用的战力,我正在努力啃官方文档学习 Angular 的知识,所以这一篇文章主要是记录我如何阅读官方文档后,实现这个非常基本的.带导航的网页应 ...

随机推荐

  1. HDU 1061 EASY

    //回宿舍去了,明天做点难一点的题,今天做的都很水,感觉.没意思.#include <iostream> #include <cstdio> using namespace s ...

  2. [Tailwind] Extending Tailwind with Responsive Custom Utility Classes

    You are able to extend the custom css with hover, focus, group-hover, responsive variants class in t ...

  3. jboss final 7.1.1相关error以及解决方式

    问题1 报错提示: MSC00001: Failed to start service jboss.web.deployment.default-host./: Caused by: java.lan ...

  4. XCODE插件 之 Code Pilot 无鼠标化

    什么是Code Pilot? Code Pilot 是一个 Xcode 5 插件.同意你不许使用鼠标就能高速地查找项目内的文件.方法和标识符. 它使用模糊查询匹配(fuzzy query matchi ...

  5. hdoj--1272--小希的迷宫(并查集)

    小希的迷宫 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Subm ...

  6. 杂项-公司:Altera

    ylbtech-杂项-公司:Altera 自二十年前发明世界上第一个可编程逻辑器件开始,Altera公司(阿尔特拉)(NASDAQ:ALTR)秉承了创新的传统,是世界上“可编程芯片系统”(SOPC)解 ...

  7. linux 下Redis 5.0主从复制(一主二从)哨兵模式的搭建

    文档结构如下: 一.环境说明: 作用 IP地址 端口 操作系统版本 安装目录 哨兵文件 主库 172.16.10.80 6379 Redhat 6.7 /redis5.0/redis-5.0.0 Se ...

  8. 【转】C#详解值类型和引用类型区别

    通用类型系统 值类型 引用类型 值类型和引用类型在内存中的部署 1 数组 2 类型嵌套 辨明值类型和引用类型的使用场合 5 值类型和引用类型的区别小结   首先,什么是值类型,什么是引用类型? 在C# ...

  9. Java 系列之spring学习--springmvc注解方式(五)

    一.springmvc注解方式 注解方式使用的更多,更加灵活.在上一篇的博客的基础上修改springmvc-servlet.xml配置文件. <?xml version="1.0&qu ...

  10. 错误:com.android.builder.packaging.DuplicateFileException: Duplicate files copied

    File2: C:\Users\guoxw\.gradle\caches\modules-2\files-2.1\org.jsoup\jsoup\1.10.3\b842f960942503cf1abb ...