new structure

This commit is contained in:
2022-10-22 15:20:59 +10:00
parent 3a4d3fea18
commit 56cbf7b140
19 changed files with 296 additions and 57 deletions

View 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();
});
});

View 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)
}
}