Answers for "core.js:6456 ERROR NullInjectorError: R3InjectorError(AppModule)[UsersService -> HttpClient -> HttpClient -> HttpClient]: NullInjectorError: No provider for HttpClient!"

9

NullInjectorError: No provider for HttpClient!

@NgModule({
...
imports:[ HttpClientModule ]
...
})
Posted by: Guest on May-31-2020
0

NullInjectorError: R3InjectorError(DynamicTestModule)[TaskService -> HttpClient -> HttpClient]: NullInjectorError: No provider for HttpClient!

import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import {HttpClientModule} from '@angular/common/http';
import { myService } from './myservice';


describe('myService', () => {

      beforeEach(() => TestBed.configureTestingModule({
        imports: [HttpClientTestingModule], 
        providers: [myService]
      }));

       it('should be created', () => {
        const service: myService = TestBed.get(myService);
        expect(service).toBeTruthy();
       });

       it('should have getData function', () => {
        const service: myService = TestBed.get(myService);
        expect(service.getData).toBeTruthy();
       });

    });
Posted by: Guest on June-15-2021

Code answers related to "core.js:6456 ERROR NullInjectorError: R3InjectorError(AppModule)[UsersService -> HttpClient -> HttpClient -> HttpClient]: NullInjectorError: No provider for HttpClient!"

Code answers related to "Javascript"

Browse Popular Code Answers by Language