new structure
This commit is contained in:
		
							
								
								
									
										16
									
								
								src/app/services/api-chat.service.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/app/services/api-chat.service.spec.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| import { TestBed } from '@angular/core/testing'; | ||||
|  | ||||
| import { ApiChatService } from './api-chat.service'; | ||||
|  | ||||
| describe('ApiChatService', () => { | ||||
|   let service: ApiChatService; | ||||
|  | ||||
|   beforeEach(() => { | ||||
|     TestBed.configureTestingModule({}); | ||||
|     service = TestBed.inject(ApiChatService); | ||||
|   }); | ||||
|  | ||||
|   it('should be created', () => { | ||||
|     expect(service).toBeTruthy(); | ||||
|   }); | ||||
| }); | ||||
							
								
								
									
										28
									
								
								src/app/services/api-chat.service.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/app/services/api-chat.service.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| import { Injectable } from '@angular/core'; | ||||
| import { HttpClient } from '@angular/common/http'; | ||||
| import { Observable } from 'rxjs'; | ||||
| import { SinglePost } from '../models/post'; | ||||
|  | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
| }) | ||||
| export class ApiChatService { | ||||
|   constructor(private http: HttpClient) { | ||||
|   } | ||||
|  | ||||
|   getPosts(): Observable<SinglePost[]> { | ||||
|     console.log("Получаю данные из сервиса"); | ||||
|     return this.http.get<SinglePost[]>('http://localhost:7141/List'); | ||||
|   } | ||||
|  | ||||
|     sendPostToApi(text: string) { | ||||
|     console.log("Отправляю пост..."); | ||||
|     var postToSend = | ||||
|     { | ||||
|       Date: Date, | ||||
|       Id: 0, | ||||
|       Text: text | ||||
|     } | ||||
|       return this.http.post('http://localhost:7141/PostTo', postToSend) | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user