79383273

Date: 2025-01-24 05:20:11
Score: 0.5
Natty:
Report link

---- service file

 getData(): Observable<any>  {
   return this.http.get(`${this.apiUrl}`);
  }

 updateData(query:any,data:any): Observable<any> {
    return this.http.put(`${this.apiUrl}/${query}`, data);
 }

 postData(data: any): Observable<any> {
   const headers = new HttpHeaders({
    'Content-Type': 'application/json',
   });
   return this.http.post(`${this.apiUrl}/add`, data, { headers });
 }

 deleteData(query:any): Observable<any> {
   return this.http.delete(`${this.apiUrl}/${query}`);
 }

---- .ts file

 this.apiService.getData(this.limit,skip).subscribe(
  (response) => {
    this.data = response.products;
    console.log('Data fetched successfully:', response.products);
  },
  (error) => {
    console.error('Error fetching data:', error);
  }
);
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: BIO GAMMER