Bug fix and format code
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
f94e9e7634
commit
a86a40e845
@ -1,7 +1,7 @@
|
|||||||
export interface Work {
|
export interface Work {
|
||||||
id_work: number,
|
id_work: number;
|
||||||
link: string,
|
link: string;
|
||||||
user_id: number,
|
user_id: number;
|
||||||
language_id: number,
|
language_id: number;
|
||||||
content: string
|
content: string;
|
||||||
}
|
}
|
@ -1,32 +1,35 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import {Work} from "../models/work.model";
|
import { Work } from '../models/work.model';
|
||||||
import {HttpClient} from "@angular/common/http";
|
import { HttpClient } from '@angular/common/http';
|
||||||
import {Observable} from "rxjs";
|
import { Observable } from 'rxjs';
|
||||||
import {NgForm} from "@angular/forms";
|
import { NgForm } from '@angular/forms';
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class WorksService {
|
export class WorksService {
|
||||||
API_URL = 'http://127.0.0.1:3000'
|
API_URL = 'http://127.0.0.1:3000';
|
||||||
|
|
||||||
private works: Work[] = [];
|
private works: Work[] = [];
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {}
|
||||||
}
|
|
||||||
|
|
||||||
getWorks(): Observable<any> {
|
getWorks(): Observable<any> {
|
||||||
return this.http.get(`${this.API_URL}/works`);
|
return this.http.get(`${this.API_URL}/works`);
|
||||||
}
|
}
|
||||||
|
|
||||||
postWork(form: NgForm): void {
|
postWork(form: NgForm): void {
|
||||||
let body = {link: form.value.link, id_user: 1, id_language: 1, code: form.value.content}
|
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();
|
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
postWorkCode(code: string): void {
|
postWorkCode(code: string): void {
|
||||||
let body = {link: 'TODO', id_user: 1, id_language: 1, code: code}
|
let body = { link: 'TODO', id_user: 1, id_language: 1, code: code };
|
||||||
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue