excellent customer service
import {Account} from '../models/Account';
export class AccountingService {
domain: string = "http://localhost:3000/api";
constructor(private http: HttpClient) { }
getAccounts(){
return this.http.get<Account[]>(`${this.domain}/accounts` )
.map(res => res)
}
addAccount(newAccount:Account){
return this.http.post(`${this.domain}/accounts`,newAccount)
.map(res=>res);
}
updateAccount(newAccount: Account){
return this.http.put(`${this.domain}/accounts/${newAccount.id}`,newAccount)
.map(res=>res);
}
deleteAccount(id){
return this.http.delete(`${this.domain}/accounts/${id}`)
.map(res=>res);
}
}
customer account model
export class Account{
_id?: string;
name: string;
amount: number;
}
service component
import {AccountingService} from '../../services/accounting.service';
@Component({
selector: 'app-accounting',
templateUrl: './accounting.component.html',
styleUrls: ['./accounting.component.css']
})
export class AccountingComponent implements OnInit {
accounts:Account[];
name:string;
amount:number;
constructor(private accountService : AccountingService ) {
this.accountService.getAccounts()
.subscribe(accounts =>{
console.log(accounts);
})
}
addAccount(event){
event.preventDefault();
const newAccount : Account={
name: this.name,
amount: this.amount
};
this.accountService.addAccount(newAccount);
}
getAccounts() is performing well, however, the addAccount function is presenting me with a
issue: Object literal may only specify known properties and 'amount' does not exist in type Account
It could be a logical mistake, but I am unsure how to resolve it at this moment