From 07c827ec1bc3041039646f81eaa2d4b104a5d937 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sun, 8 Oct 2023 00:59:00 +0200 Subject: [PATCH] replace deprecated toPromise with last value --- .../app/model/network/network.service.ts | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/frontend/app/model/network/network.service.ts b/src/frontend/app/model/network/network.service.ts index 920656de..dc0ae2f6 100644 --- a/src/frontend/app/model/network/network.service.ts +++ b/src/frontend/app/model/network/network.service.ts @@ -7,6 +7,7 @@ import {Config} from '../../../../common/config/public/Config'; import {Utils} from '../../../../common/Utils'; import {CustomHeaders} from '../../../../common/CustomHeaders'; import {VersionService} from '../version.service'; +import { lastValueFrom } from 'rxjs'; @Injectable() export class NetworkService { @@ -50,9 +51,8 @@ export class NetworkService { return this.handleError(error); }; - return this.http - .get(this.apiBaseUrl + url, {responseType: 'text'}) - .toPromise() + return lastValueFrom(this.http + .get(this.apiBaseUrl + url, {responseType: 'text'})) .then(process) .catch(err); } @@ -70,9 +70,8 @@ export class NetworkService { return this.handleError(error); }; - return this.http - .get(this.apiBaseUrl + url, {responseType: 'text'}) - .toPromise() + return lastValueFrom(this.http + .get(this.apiBaseUrl + url, {responseType: 'text'})) .then(process) .catch(err); } @@ -130,29 +129,25 @@ export class NetworkService { switch (method) { case 'get': - return this.http - .get>(this.apiBaseUrl + url, {observe: 'response'}) - .toPromise() + return lastValueFrom(this.http + .get>(this.apiBaseUrl + url, {observe: 'response'})) .then(process) .catch(err); case 'delete': - return this.http - .delete>(this.apiBaseUrl + url, {observe: 'response'}) - .toPromise() + return lastValueFrom(this.http + .delete>(this.apiBaseUrl + url, {observe: 'response'})) .then(process) .catch(err); case 'post': - return this.http + return lastValueFrom(this.http .post>(this.apiBaseUrl + url, body, { observe: 'response', - }) - .toPromise() + })) .then(process) .catch(err); case 'put': - return this.http - .put>(this.apiBaseUrl + url, body, {observe: 'response'}) - .toPromise() + return lastValueFrom(this.http + .put>(this.apiBaseUrl + url, body, {observe: 'response'})) .then(process) .catch(err); default: