{"id":15485801,"url":"https://github.com/overlineink/http-chapter","last_synced_at":"2026-05-03T04:37:43.164Z","repository":{"id":97621617,"uuid":"156383458","full_name":"overlineink/http-chapter","owner":"overlineink","description":"Consuming HTTP services and making a reusable data service for HTTPs classes","archived":false,"fork":false,"pushed_at":"2018-11-10T17:45:19.000Z","size":155,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-02T15:48:50.006Z","etag":null,"topics":["angular","best-practices","http","separation-of-concerns","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/overlineink.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-06T12:53:36.000Z","updated_at":"2019-02-05T14:06:05.000Z","dependencies_parsed_at":"2023-04-08T06:16:47.239Z","dependency_job_id":null,"html_url":"https://github.com/overlineink/http-chapter","commit_stats":{"total_commits":41,"total_committers":1,"mean_commits":41.0,"dds":0.0,"last_synced_commit":"bb84f67dba6a4c7f4672713a82e6f018065d8700"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overlineink%2Fhttp-chapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overlineink%2Fhttp-chapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overlineink%2Fhttp-chapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overlineink%2Fhttp-chapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/overlineink","download_url":"https://codeload.github.com/overlineink/http-chapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246056607,"owners_count":20716771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","best-practices","http","separation-of-concerns","typescript"],"created_at":"2024-10-02T06:03:19.973Z","updated_at":"2026-05-03T04:37:43.137Z","avatar_url":"https://github.com/overlineink.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📖 Chapter 9 - Consuming HTTP Services\n\nThis project is part of the Angular Series Program, in this episode we present the readjustments of [Angular](https://angular.io) version 7.0.3.\n\nWe also present good practices when consuming HTTP services, we also had a brief consideration of the handling of errors for HTTP services (unexpected errors, global errors and specific errors) and to create a reusable service following the Clean Code Guides * Separation of concepts.\n\n# Quick Start 🚀\n\n#### Example: Posts Page\n\n* Clone this repo\n\u003cpre\u003egit clone https://github.com/overlineink/http-chapter.git\u003c/pre\u003e\n\n* Open this project on your favorite editor or IDE. For this example I was using [vscode](https://code.visualstudio.com/) a powerfull editor.\n\u003cpre\u003ecode . \u003c/pre\u003e\n\nInstall dependencies\n\u003cpre\u003e npm install \u003c/pre\u003e\n\n⚠ Note: Open your command line inside the folder of your project before installing the dependencies\n⚠ Advice: Generate your own services and use 'em with DataService class.\n\nGenerating `Posts` Service\n\u003cpre\u003eng generate service services/post\u003c/pre\u003e or use that for short  \u003cpre\u003eng g s services/post\u003c/pre\u003e\n\n* Extends `DataService` class and passing expected params. \n\n\u003cpre lang=typescript\u003e\n    import { Injectable } from '@angular/core';\n    import { Http } from '@angular/http';\n    import { DataService } from '../data.service';\n    \n    @Injectable({\n    providedIn: 'root'\n    })\n    \n    export class PostsService extends DataService {\n    \n        constructor(http : Http) {\n            super('https://jsonplaceholder.typicode.com/comments', http);\n        }\n\n    }\n\u003c/pre\u003e\n\n* Generate `Posts` component\n\n\u003cpre\u003eng g c components/post\u003c/pre\u003e\n\n* Consuming our `Posts` service\n\n\u003cpre lang=typescript\u003e\n    import { Component, OnInit } from '@angular/core';\n    import { PostsService } from 'src/app/services/posts/posts.service';\n\n    @Component({\n    selector: 'app-posts',\n    templateUrl: './posts.component.html',\n    styleUrls: ['./posts.component.css']\n    })\n    export class PostsComponent implements OnInit {\n\n        // public helper to store posts data\n        posts = [];\n\n        constructor(private service: PostsService) { }\n\n        //...\n\n        ngOnInit() {\n            this.service.getAll()\n            .subscribe(posts =\u003e this.posts = posts);\n        }\n\n    }\n\n\u003c/pre\u003e\n\n* Adding posts to our `Posts` template\nIn this example I use Bootstrap css classes to make our app friendly.\n\n```\n    \u003cp class=\"media-body pb-3 mb-0 small lh-125 border-bottom border-gray\"\u003e\n        \u003cstrong class=\"d-block text-gray-dark\"\u003e\n            {{ post.email }}\n        \u003c/strong\u003e\n        {{ post.body }}\n    \u003c/p\u003e\n```\n\n* Serve your project and enjoy 🐱‍👓\n\n\u003cpre\u003e ng serve --open \u003c/pre\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foverlineink%2Fhttp-chapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foverlineink%2Fhttp-chapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foverlineink%2Fhttp-chapter/lists"}