Skip to content

Instantly share code, notes, and snippets.

@P1xt
Created March 14, 2017 02:41
Show Gist options
  • Save P1xt/bf0bc3c4b0a9c1565d1bf1c70c1a59ab to your computer and use it in GitHub Desktop.
Save P1xt/bf0bc3c4b0a9c1565d1bf1c70c1a59ab to your computer and use it in GitHub Desktop.
Simple Angular 2 Service to read data from an http get request
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