Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
A close look to Angular's new HttpClient
Search
Manfred Steyer
PRO
December 09, 2017
Programming
450
1
Share
A close look to Angular's new HttpClient
Presentation from ng-be in December 2017.
Manfred Steyer
PRO
December 09, 2017
More Decks by Manfred Steyer
See All by Manfred Steyer
Agentic UI beyond Chats Architecture Patterns & Open Standards @ngMunich 05/2026
manfredsteyer
PRO
0
130
Agentic AI in the Frontend: Architectures with Open Standards @iJS London 2026
manfredsteyer
PRO
0
95
Agentic AI & UI: Arcitecture, HITL, Emerging Standards
manfredsteyer
PRO
0
120
Agentic UI Requires Standards: AG-UI, A2UI, and MCP Apps Work Together @Angular London
manfredsteyer
PRO
1
72
Signal Forms: Beyond the Basics @ngBelgrade 2026
manfredsteyer
PRO
0
190
Agentic UI in the Frontend: Architectures with Open Standards @JAX 2026 in Mainz
manfredsteyer
PRO
0
120
Rethinking Angular: The Future with Signal Store and the New Resource API @JAX 2024 in Mainz
manfredsteyer
PRO
0
80
Agentic UI with Angular @ngAir April 2025
manfredsteyer
PRO
0
190
Migration to Signals, Signal Forms, Resource API, and NgRx Signal Store @Angular Days 03/2026 Munich
manfredsteyer
PRO
0
370
Other Decks in Programming
See All in Programming
PHPでバイナリをパースして理解するASN.1
muno92
PRO
0
470
色即是空、空即是色、データサイエンス
kamoneggi
1
140
ふにゃっとしない名前の付け方 〜哲学で茹で上げる、コシのあるソフトウェア設計〜
shimomura
0
130
cloudnative conference 2026 flyle
azihsoyn
1
200
RailsTokyo 2026#4: AI様があれば、 Hotwireの弱点は消えるか?
naofumi
4
500
Skillは並べた。動かなかった。契約で繋いだ。— 65個のSkillから、自走する開発サイクルへ
junholee
0
680
Hive Metastoreを通して学ぶIceberg REST Catalog ― 仕様から実装まで
okumin
0
240
Spec-Driven Development with AI Agents (Workshop, May 2026)
antonarhipov
4
410
~ 秘伝のタレ化した『神スプシ』と戦う ~ 関数型パラダイムで壊れない仕組みへ
h0r15h0
1
120
PHPでローカル環境用のSSL/TLS証明書を発行することはできるのか? #phpconkagawa
akase244
0
380
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
460
Firefoxにコントリビューションして得られた学び
ken7253
2
170
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
54k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
700
A better future with KSS
kneath
240
18k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
190
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
140
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
380
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
The SEO Collaboration Effect
kristinabergwall1
1
450
Transcript
A close look to Angular's new HttpClient Manfred Steyer SOFTWAREarchitekt.at
About me … • Manfred Steyer • Angular Workshops and
Consultancy • SOFTWAREarchitekt.at • Google Developer Expert (GDE) Page ▪ 2 Manfred Steyer
In the old days, everything was better ;-)
Just a few examples …
Http in Angular Http (Service) • Angular 2+ • Most
Common Use Cases (80:20 principle) • Experimental • Deprecated with 5.0 HttpClient • Angular 4.3 • A lot of additional features • Full comfort we know from $http
Contents • Short overview of Basics • Custom Data Formats
(Binary, Text) • Progress Information • Interceptors for Extensions • Token-based Security
DEMO
angular-crud
None
Basics
HttpClient HttpClientModule and HttpClient from @angular/common/http let url = 'http://www.angular.at/api/hotel';
let headers = new HttpHeaders() .set('Accept', 'application/json'); let params = new HttpParams() .set('city', this.city); this .http .get<Hotel[]>(url, { headers, params }) .subscribe( hotels => console.debug('hotels', hotels), err => console.error('err', err) );
Getting the full HttpResponse save(entity: HotelBooking): Observable<string> { let url
= […] let headers = […] return this.http .post<HotelBooking>(url, entity, {headers, observe: 'response'}) […] }
Getting the full HttpResponse save(entity: HotelBooking): Observable<string> { let url
= […] let headers = […] return this.http .post<HotelBooking>(url, entity, {headers, observe: 'response'}) .pipe( map((response: HttpResponse<HotelBooking>) => { console.debug('status', response.status); console.debug('body', response.body); return response.headers.get('Location'); })); }
Testing
Main Idea: Mock the HttpBackend HttpClientTestingModule Your Code Test HttpClient
HttpBackend Server MockBackend
Testing it('can load hotels by city', () => { let
service: HotelService = TestBed.get(HotelService); let ctrl: HttpTestingController = TestBed.get(HttpTestingController); […] });
Testing it('can load hotels by city', () => { let
service: HotelService = TestBed.get(HotelService); let ctrl: HttpTestingController = TestBed.get(HttpTestingController); service.find({ city: 'Graz' }).subscribe( hotels => expect(hotels.length).toBe(2), err => fail(err) ); […] });
Testing it('can load hotels by city', () => { let
service: HotelService = TestBed.get(HotelService); let ctrl: HttpTestingController = TestBed.get(HttpTestingController); service.find({ city: 'Graz' }).subscribe( hotels => expect(hotels.length).toBe(2), err => fail(err) ); let req = ctrl.expectOne('/hotel?city=Graz'); expect(req.request.method).toBe('GET'); […] });
Testing it('can load hotels by city', () => { let
service: HotelService = TestBed.get(HotelService); let ctrl: HttpTestingController = TestBed.get(HttpTestingController); service.find({ city: 'Graz' }).subscribe( hotels => expect(hotels.length).toBe(2), err => fail(err) ); let req = ctrl.expectOne('/hotel?city=Graz'); expect(req.request.method).toBe('GET'); req.flush([{id: 1, name: 'Hotel Mama'}, {id: 2, name: 'Budget Hotel'}]); ctrl.verify(); });
Custom Data Formats (Text and Binary)
Using XML findById(id: string): Observable<HotelBooking> { […] return this.http .get(url,
{ headers, params, responseType: 'text'}) […] }
Using XML findById(id: string): Observable<HotelBooking> { […] return this.http .get(url,
{ headers, params, responseType: 'text'}) .pipe( switchMap(xmlString => { let observableFactory = bindCallback(parseString); return observableFactory(xmlString, parserOptions); }), map(js => js[1].hotelBooking) ); } import { parseString } from 'xml2js';
DEMO
Interceptors
Idea • Providing a hook • Modify requests and responses
globally • Including Headers, e. g. for Auth. • Parsing Data Formats, like XML • Error Handling • Caching • …
Chain of Responsibility Logic (HttpRequest) Interceptor Interceptor Request Response
DEMO Sending Access Token for Auth Global Error Handler for
Auth
Conclusion observe: response, events, … responseType: text, blob, … Interceptor
Chain The Dark Knight: Best Movie ever!
Contact und Downloads [mail]
[email protected]
[blog] SOFTWAREarchitekt.at [twitter] ManfredSteyer