What would be the equivalent of file_get_contents ($ url) in JavaScript or TypeScript?

0

I am developing an application with ionic 2 and I want to extract some data from an external page in another domain, and the way I have solved it is with PHP in the following way:

miPhp.php     

    //$url = 'http://www.flalottery.com/fantasy5';
    $url = 'http://www.flalottery.com/exptkt/ff.html';
    $pagina = file_get_contents($url);
    echo  $pagina;
?>

home.ts

import { Http } from '@angular/http';
import 'rxjs/add/operator/map'
import { NavController } from 'ionic-angular';
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController,
              public http:  Http ) {
     this.http.get('http://localhost/miPhp.php').subscribe(
       datos => console.log(datos._body))
  }
}

The php file is running on a local Apache server.

How can I do what the file php does but with JavaSecript or TypeScript ?

    
asked by Daniel Enrique Rodriguez Caste 29.10.2017 в 03:44
source

0 answers