6 changed files with 172 additions and 78 deletions
-
1.gitignore
-
1package.json
-
21src/app/pages/home/home.component.html
-
93src/app/pages/home/home.component.ts
-
28src/app/pages/home/home.service.ts
-
44src/app/pages/login/login/login.component.ts
@ -1,21 +1,41 @@ |
|||||
// Angular imports
|
// Angular imports
|
||||
import { Injectable } from '@angular/core'; |
import { Injectable } from '@angular/core'; |
||||
import { HttpClient } from '@angular/common/http'; |
|
||||
|
import { HttpClient, HttpHeaders } from '@angular/common/http'; |
||||
import { Observable } from 'rxjs'; |
import { Observable } from 'rxjs'; |
||||
// Local imports
|
// Local imports
|
||||
import { IHomeRequest, IHomeResponse } from '../../../app/model/home'; |
import { IHomeRequest, IHomeResponse } from '../../../app/model/home'; |
||||
|
|
||||
|
const httpOptions = { |
||||
|
headers: new HttpHeaders({ |
||||
|
'Content-Type': 'application/json', |
||||
|
Authorization: |
||||
|
'Basic 2b8cba9008e1da2f2733ff8300cf1973-dc928670-56f9-4a29-8725-69239d669e74', |
||||
|
}), |
||||
|
}; |
||||
|
|
||||
|
// Authorization: 'Basic SW50ZXJuYXRpb25hbFdBX1BPQzpFeHBvcnRzITIwMjE=',
|
||||
|
|
||||
|
const url = 'http://localhost:3000/'; |
||||
|
const whatsAppUrl = |
||||
|
'https://mpwyr4.api.infobip.com/whatsapp/1/message/template'; |
||||
|
|
||||
@Injectable({ |
@Injectable({ |
||||
providedIn: 'root' |
|
||||
|
providedIn: 'root', |
||||
}) |
}) |
||||
export class HomeService { |
export class HomeService { |
||||
private baseUrl = 'http://localhost:8000/home'; |
private baseUrl = 'http://localhost:8000/home'; |
||||
|
|
||||
constructor(private http: HttpClient) { |
|
||||
} |
|
||||
|
constructor(private http: HttpClient) {} |
||||
|
|
||||
post(data: any): Observable<any> { |
post(data: any): Observable<any> { |
||||
return this.http.post<any>(this.baseUrl, data); |
return this.http.post<any>(this.baseUrl, data); |
||||
} |
} |
||||
|
|
||||
|
sendEmail(body: any): Observable<any> { |
||||
|
return this.http.post(url + 'sendEmail', body, httpOptions); |
||||
|
} |
||||
|
|
||||
|
sendWhatsApp(body: any): Observable<any> { |
||||
|
return this.http.post(whatsAppUrl, body, httpOptions); |
||||
|
} |
||||
} |
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue