Skip to content

Instantly share code, notes, and snippets.

@chrisegb
Created April 8, 2020 03:50
Show Gist options
  • Save chrisegb/1c51c5e60956c991078f2e506a860c7f to your computer and use it in GitHub Desktop.
Save chrisegb/1c51c5e60956c991078f2e506a860c7f to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { HttpHeaders } from '@angular/common/http'
@Injectable({
providedIn: 'root'
})
export class ApiService {
BASE_URL = "https://limitless-beach-92120.herokuapp.com/";
BASE_LOCAL_URL = "http://localhost:5000/";
httpHeaders = new HttpHeaders({
"Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept, Cache-Control, Key, Access-Control-Allow-Origin",
"Access-Control-Allow-Origin": "*"
});
options = {
headers: this.httpHeaders
};
constructor(private httpClient: HttpClient) { }
public createPost(json){
return this.httpClient.post(this.BASE_URL+"post/crearPost", json, this.options);
}
public uploadMedia(formData){
return this.httpClient.post(this.BASE_URL+"uploadFile", formData);
}
public deleteMedia(json){
return this.httpClient.post(this.BASE_URL+"deleteFile", json);
}
public getPostById(json){
return this.httpClient.post(this.BASE_URL+"post/seleccionarPost", json, this.options);
}
public getPostsOrderedByDate(json){
return this.httpClient.post(this.BASE_URL+"post/postsOrdenadoPorFecha", json, this.options);
}
public getPostsByIdCategory(json){
return this.httpClient.post(this.BASE_URL+"post/seleccionarPostsPorIdCategoria", json, this.options);
}
public searchPost(json){
return this.httpClient.post(this.BASE_URL+"post/buscarPost", json, this.options);
}
public login(json){
return this.httpClient.post(this.BASE_URL+"usuario/login", json, this.options);
}
public deletePost(json){
return this.httpClient.post(this.BASE_URL+"post/borrarPost", json, this.options);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment