Search code examples
angularapiserviceangular8

how to create web service Api in Angular 8?


can anyone help me how to create a web service API in angular 8. I am in new in angular 8. I am currently working on angular 8 project. Please Help..

from POSTMAN => api


Solution

  • on terminal write : ng g s service name

    inject httpclient which you add in appmodule as HttpClientModule

      constructor(private http:HttpClient) { }
    

    then simply add you methods like this

      getUser(id:any):Observable<User>{
    return this.http.get<User>(your url from api + 'user/' + id)
    

    }

    hope this help