parent
082aabf658
commit
fa16b536a8
@ -1,35 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { Work } from '../models/work.model';
|
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { NgForm } from '@angular/forms';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root',
|
|
||||||
})
|
|
||||||
export class WorksService {
|
|
||||||
API_URL = 'http://127.0.0.1:3000';
|
|
||||||
|
|
||||||
private works: Work[] = [];
|
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
|
||||||
|
|
||||||
getWorks(): Observable<any> {
|
|
||||||
return this.http.get(`${this.API_URL}/works`);
|
|
||||||
}
|
|
||||||
|
|
||||||
postWork(form: NgForm): void {
|
|
||||||
let body = {
|
|
||||||
link: form.value.link,
|
|
||||||
id_user: 1,
|
|
||||||
id_language: 1,
|
|
||||||
code: form.value.content,
|
|
||||||
};
|
|
||||||
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
postWorkCode(code: string): void {
|
|
||||||
let body = { link: 'TODO', id_user: 1, id_language: 1, code: code };
|
|
||||||
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue