Home:ALL Converter>angular 6 how to fetch data from YTS API

angular 6 how to fetch data from YTS API

Ask Time:2018-09-29T02:40:16         Author:Anthony Fink

Json Formatter

hello somebody can help me to fetch data from YTS API

service.ts

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {Movies} from '../models/movies.model';

@Injectable ()

export class MovieRequestService {
  private url = 'https://yts.am/api/v2/list_movies.json?limit=50';
  moviesData: {movies: Movies} = {
    movies: undefined
  };
  constructor(private myHttp: HttpClient ) {
    this.myHttp.get(this.url).subscribe(
      (response: Movies) => { this.moviesData.movies  = response; });
    console.log(this.moviesData);
  }
}

Author:Anthony Fink,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/52561049/angular-6-how-to-fetch-data-from-yts-api
yy