UNPKG

ruffer-pattern-portfolio

Version:

This is the end result from https://dev.to/swyx/quick-guide-to-setup-your-react--typescript-storybook-design-system-1c51

34 lines (33 loc) 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var HttpService = /** @class */ (function () { function HttpService() { this.url = "http://localhost:4000/"; } HttpService.prototype.api = function (url) { return fetch(url) .then(function (response) { if (!response.ok) { throw new Error(response.statusText); } return response.json(); }) .catch(function (error) { throw error; /* <-- rethrow the error so consumer can still catch it */ }); }; HttpService.prototype.getRecentDocuments = function () { return this.api(this.url + "recent-document") .then(function (docsResult) { return docsResult; }); }; HttpService.prototype.getTeamList = function () { return this.api(this.url + "team-list") .then(function (teamsResult) { return teamsResult; }); }; return HttpService; }()); exports.default = HttpService;