I'm having this error message:
ERROR Error: StaticInjectorError[CervejaService]:
StaticInjectorError[CervejaService]:
NullInjectorError: No provider for CervejaService!
at _NullInjector.get (core.js:993)
at resolveToken (core.js:1281)
at tryResolveToken (core.js:1223)
at StaticInjector.get (core.js:1094)
at resolveToken (core.js:1281)
at tryResolveToken (core.js:1223)
at StaticInjector.get (core.js:1094)
at resolveNgModuleDep (core.js:10878)
at NgModuleRef_.get (core.js:12110)
at resolveDep (core.js:12608)
And I'm sure it's because of this line of code:
import { Cerveja } from './../core/model';
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
@Injectable()
export class CervejaService {
cervejasUrl = 'http://localhost:8080/cervejas';
constructor(private http: Http) { }
adicionar(cerveja: Cerveja): Promise<Cerveja> {
return this.http.post(this.cervejasUrl,
JSON.stringify(cerveja))
.toPromise()
.then(response => response.json());
}
}
How do I know what's coming back?
Would there be any way to apply a console.log
to this method?