adding api request

Solutions on MaxInterview for adding api request by the best coders in the world

showing results for - "adding api request"
Davion
30 Jun 2017
1import { Component, OnInit } from '@angular/core';import { HttpClient } from '@angular/common/http';...import { Quote } from '../quote-class/quote';....export class GoalComponent implements OnInit {    goals:Goal[];  alertService:AlertService;  quote:Quote;....  constructor(goalService:GoalService, alertService:AlertService, private http:HttpClient) {    this.goals = goalService.getGoals()    this.alertService = alertService;  }  ngOnInit() {    interface ApiResponse{      author:string;      quote:string;    }    this.http.get<ApiResponse>("http://quotes.stormconsultancy.co.uk/random.json").subscribe(data=>{      // Succesful API request      this.quote = new Quote(data.author, data.quote)    })  }}
similar questions
components of api request
queries leading to this page
adding api requestadding api request