Welcome, HttpClientModule
HttpModule has been deprecated since Angular 4.3, but hadn’t been replaced yet. Now to prepare for the coming version 6 where it’s not supported anymore, we just got rid of it to welcome the newer HttpClientModule.
All objects from the “@angular/http” package are obsolete and have been replaced by objects from “@angular/common/http”. It was also the opportunity to have a good spring cleaning of those areas of code.
As we’re still receiving mixed types of server response (the version is still hybrid with legacy Symfony mechanisms), we indicate in the HttpClient calls options: observe = ‘response’, so the response we receive is not directly json-decoded, but returned as is.
Especially, the @ngx-translate/http-loader, which is responsible for loading the i18n translation files, has been upgraded from 0.1.0 to 2.0.1 to support the new HttpClient.
Tests
Tests were a bit verbose before when it got to Http. They are now simplified by the use and import in TestBed of the newer module:
import { HttpClientTestingModule } from ‘@angular/common/http/testing’;
