http

PHOTO EMBED

Mon Dec 20 2021 01:02:10 GMT+0000 (Coordinated Universal Time)

Saved by @Tazeen

import { Injectable } from "@angular/core";
// we need these imports in order to do any http requests
import { Http, Response, Headers, RequestOptions } from "@angular/http";
import { Observable } from "rxjs/Rx";

@Injectable()
export class ArticleService {
  constructor(private http: Http) {}

  getArticles() {
    return this.http
      .get("http://localhost:8000/api/lessons")
      .map((res: Response) => res.json())
      .catch((error: any) =>
        Observable.throw(error.json().error || "Server Error")
      );
  }
}
content_copyCOPY