我正在尝试使用登录功能,但出现此错误 https://image.noelshack.com/fichiers/2020/40/6/1601742042-1.jpg。
登录功能代码:
onSubmit(){
console.log(this.form)
this.Jarwis.login(this.form).subscribe(
data => {this.handleResponse(data)
console.log(data)},
error => this.handleError(error)
)
}
jarwis服务代码:
export class JarwisService {
constructor(private http:HttpClient) { }
apiUrl="http://127.0.0.1:8000/api/auth"
public login(data){
return this.http.post(`${this.apiUrl}/login`,data);
}}
最后,这是我的登录组件代码+我的角度架构师代码:https://image.noelshack.com/fichiers/2020/40/6/1601742370-2.jpg
答案 0 :(得分:1)
您可以确定您的服务可以注射吗?
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root',
})
export class HeroService {
constructor() { }
}