Hey everyone, I hope you're having a good morning. Apologies for the inconvenience, I've been practicing to improve my skills and encountered an issue while working on a login feature. I'm trying to connect it to an API but facing a strange error in the login component.
import { Component, } from '@angular/core';
import { AppserviceService } from '../../services/appservice.service';
import { NgForm } from '@angular/forms';
import { AppsResp } from '../../interfaces/interfaces';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
})
export class LoginComponent {
email:string ='';
password:string='';
constructor(public AppserviceService: AppserviceService) { }
login() {
const user = {email: this.email, password: this.password};
this.AppserviceService.login(user).subscribe( data => {
console.log(data);
});
}
}
The specific error message I'm receiving is as follows: "Expected 2 arguments, but got 1.ts(2554) appservice.service.ts(15, 26): An argument for 'password' was not provided."
Below, you'll find the code for the app service where the error originates:
import { HttpClient } from '@angular/common/http';
import { Injectable, Query } from '@angular/core';
import { Observable } from 'rxjs';
import { AppsResp, Registro } from '../interfaces/interfaces';
@Injectable({
providedIn: 'root'
})
export class AppserviceService {
constructor(private http: HttpClient) { }
login ( email: string, password: string ){
const body = {email,password}
return this.http.post <AppsResp>("http://apitest.e-bango.com/api/auth/login" , body );
}
}
I'm also struggling with incorporating the registration component into my service correctly. Could someone please assist me and provide detailed explanations of any mistakes I may have made? Thank you so much!