-1

I can not under Stand How to Edit or Delete Get/Post API data in Ionic. I'm tried to Edit And Delete ionic Post/Get data using API. please some body help me in this ionic operation. it's argent to me. #huge_request

Vinay Mali
  • 17
  • 6

1 Answers1

0

First in an Ionic/Angular project you'll need to import HttpClient in your TS file or service. And then use it in your function.

 import { HttpClient } from '@angular/common/http';
 constructor(private http: HttpClient) {}

You need to understand that you'll get a result as an Observable (https://angular.io/guide/observables). For your function to work, you'll need to subscribe to it.

Example you have a function in a service.ts file:

getData(id: string) {

 return this.http.get(url, option or what the api need)
 // you might need to use observable manipulation like pipe or map to get the data you want


}

In the ts file you use the service :

 import {service} from 'Service'

 constructor (private service: Service) {}


 function() {
    service.getData(id).subscribe(res => {
     console.log(res)

    })
 }



 
uKioops
  • 269
  • 3
  • 8