Skip to content

Instantly share code, notes, and snippets.

@webmasterdevlin
Created November 17, 2019 10:33
Show Gist options
  • Save webmasterdevlin/601564cc573a9e59cf7c61b213ec4e07 to your computer and use it in GitHub Desktop.
Save webmasterdevlin/601564cc573a9e59cf7c61b213ec4e07 to your computer and use it in GitHub Desktop.
Http Service
import http from "../shared/http.service";
import { BaseUrl } from "../api.config";
export async function getHeroes() {
return await http.get(BaseUrl.heroes);
}
export async function getHeroById(id) {
return await http.get(`${BaseUrl.heroes}${id}`);
}
export async function postHero(hero) {
return await http.post(BaseUrl.heroes, hero);
}
export async function putHero(hero) {
console.log(hero);
return await http.put(`${BaseUrl.heroes}${hero._id}`, hero);
}
export async function deleteHero(id) {
return await http.delete(`${BaseUrl.heroes}${id}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment