Skip to content

Commit 217b76c

Browse files
committed
chore(): updated newsletter service
1 parent 2b7fd20 commit 217b76c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import { HttpClient } from '@angular/common/http';
22
import { Injectable } from '@angular/core';
3-
import { EMPTY } from 'rxjs';
3+
import { EMPTY, lastValueFrom } from 'rxjs';
44
import { catchError } from 'rxjs/operators';
55

66
@Injectable({ providedIn: 'root' })
77
export class NewsletterService {
88
constructor(private readonly httpClient: HttpClient) {}
99

10-
addToNewsletter(email: string): Promise<any> {
10+
async addToNewsletter(email: string): Promise<any> {
1111
const newsletterUrl =
1212
'https://z93f42xq2l.execute-api.us-east-2.amazonaws.com/Stage/newsletter?token=db1f899025b5a59a76b6b34b2a013893';
13-
return this.httpClient
14-
.post(newsletterUrl, { email })
15-
.pipe(catchError(() => EMPTY ))
16-
.toPromise();
13+
return await lastValueFrom(
14+
this.httpClient
15+
.post(newsletterUrl, { email })
16+
.pipe(catchError(() => EMPTY)),
17+
);
1718
}
1819
}

0 commit comments

Comments
 (0)