import { Component } from '@angular/core'; import { AuthService } from './shared/auth.service'; //... export class AppComponent { title = 'app01'; constructor(private auth: AuthService) {} logout() { let jsonUserData: any = localStorage.getItem('userData'); let userData = JSON.parse(jsonUserData); console.log(userData.name); console.log(userData.token); this.auth.logout(userData.name, userData.token).subscribe({ next: res => { console.log(res) } }); } }