aaronksaunders / ionic2-ts-http-example

2 stars 1 forks source link

It doesn't work for me... #1

Open mamarilmanson opened 8 years ago

mamarilmanson commented 8 years ago

Hi... I tried this example... used it in my app... modified it to look like this:

import { Page } from 'ionic-angular';
import { Http, Headers } from 'angular2/http';
import 'rxjs/add/operator/map';

@Page({
  templateUrl: 'build/pages/home/home.html',
})
export class WeekViewPage {

  /**
  * inject the HTTP service into the component
  */

  constructor(private http: Http, private randomUser) { // CHANGES HERE
    this.http = http;
    this.getRandomUser()
  }

  /**
   * gets user using random.me api
   */
  getRandomUser() {
    this.http.get('https://randomuser.me/api/')
      .map(res => res.json()) // convert json
      .subscribe(
        data => this.randomUser = data.results[0].user,
        err => console.log('Random User', err)
      );
  }
}

But it presented an error in my console: query error

aaronksaunders commented 8 years ago

apologies for late response, did you get this resolved?

mamarilmanson commented 8 years ago

thanks for answering...

yes... mine is working now... :)