File

src/app/user.service.ts

Index

Methods

Constructor

constructor(http: HttpClient)
Parameters :
Name Type Optional
http HttpClient No

Methods

getUser
getUser()
Returns : Observable<User>
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

export interface User {
  id: string;
  address: string;
  phone: string;
}

@Injectable({
  providedIn: 'root'
})
export class UserService {
  constructor(private http: HttpClient) { }

  getUser(): Observable<User> {
    // Make an HTTP request to fetch the user's information from the backend
    return this.http.get<User>('http://localhost:3000/user');
  }
}

results matching ""

    No results matching ""