Created
March 14, 2017 02:41
-
-
Save P1xt/bf0bc3c4b0a9c1565d1bf1c70c1a59ab to your computer and use it in GitHub Desktop.
Simple Angular 2 Service to read data from an http get request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { Http, Response } from '@angular/http'; | |
@Injectable() | |
export class AllTimeService { | |
constructor(private http: Http) { } | |
getCampers = () => { | |
let apiUrl: string = 'https://fcctop100.herokuapp.com/api/fccusers/top/alltime'; | |
return this.http | |
.get(apiUrl) | |
.map(response => response.json()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment