mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { HttpContext, HttpHeaders, HttpParams } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { HttpClient, HttpResponse, HttpErrorResponse } from '@angular/common/http';
|
|
import { tap, shareReplay, catchError } from "rxjs/operators";
|
|
import { Observable, of } from "rxjs";
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class HttpServiceService {
|
|
|
|
constructor(private http: HttpClient) {}
|
|
|
|
|
|
put(url: string, body: any | null, options: Options): Observable<any> {
|
|
return this.http.put(url, body, options as any).pipe(
|
|
tap((response) => {
|
|
// Handle success response if needed
|
|
}),
|
|
catchError((error) => {
|
|
// Handle error response if needed
|
|
return of(error);
|
|
})
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Options {
|
|
headers?: HttpHeaders | {
|
|
[header: string]: string | string[];
|
|
};
|
|
context?: HttpContext;
|
|
observe?: 'body';
|
|
params?: HttpParams | {
|
|
[param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
|
|
};
|
|
reportProgress?: boolean;
|
|
responseType?: 'arraybuffer';
|
|
withCredentials?: boolean;
|
|
}
|