Skip to content

Instantly share code, notes, and snippets.

@michaelchadwick
Created June 14, 2017 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelchadwick/59de56c93df8ffcaee933083bfa1d618 to your computer and use it in GitHub Desktop.
Save michaelchadwick/59de56c93df8ffcaee933083bfa1d618 to your computer and use it in GitHub Desktop.
angular 2 testing - DaveService
import { Injectable } from '@angular/core';
import { Headers, Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import { devlog } from '../_helpers/devlog';
@Injectable()
export class DaveService {
private localAPI = 'http://localhost:3002/?api=1';
constructor(private http: Http) {}
daveCheckObservable() {
devlog('api', 'daveService.daveCheckObservable()')
return this.http.get(this.localAPI)
.map((response: Response) => {
return response.json();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment