message service
This commit is contained in:
parent
18600e2874
commit
dfcd49bcdb
2 changed files with 52 additions and 0 deletions
36
frontend/src/app/services/message/message.service.ts
Normal file
36
frontend/src/app/services/message/message.service.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
|
||||
import {Observable} from 'rxjs';
|
||||
import {environment} from "../../../environments/environment";
|
||||
|
||||
export interface JSdata{
|
||||
status: string;
|
||||
data: any;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
|
||||
export class MessageService {
|
||||
|
||||
constructor(private http: HttpClient) { }
|
||||
sendMessage(url: string, data: any): Observable<JSdata> {
|
||||
const CreatURL = environment.urlCL.concat('/').concat(url);
|
||||
const FData = new FormData();
|
||||
let i: any;
|
||||
if (data !== null && data !== undefined) {
|
||||
for (i of Object.keys(data)){
|
||||
FData.append(i, data[i]);
|
||||
}
|
||||
}
|
||||
return this.http.post<JSdata>(
|
||||
CreatURL,
|
||||
FData,
|
||||
{withCredentials: true}
|
||||
);
|
||||
return this.http.post<JSdata>(CreatURL, {withCredentials: true});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in a new issue