Issue using http.get


#1

I am getting error as net::ERR_INCOMPLETE_CHUNKED_ENCODING
when I try to send the get request for https://randomuser.me/api/?results=1000

Here is the app:
http://blog.ionic.io/10-minutes-with-ionic-2-calling-an-api/

I am not sure this is error with ionic2 or not?


#2

We need more information that what you have provided.
Could you please provide some code?


#3

When I try to use below code, some times I am getting error as

net::ERR_INCOMPLETE_CHUNKED_ENCODING

import {Injectable} from 'angular2/core';
import {Http} from 'angular2/http';
import 'rxjs/add/operator/map';

/*
  Generated class for the PeopleService provider.
  See https://angular.io/docs/ts/latest/guide/dependency-injection.html
  for more info on providers and Angular 2 DI.
*/
@Injectable()
export class PeopleService {
  data: any = null;

  constructor(public http: Http) {}

  load() {
    if (this.data) {
      // already loaded data
      return Promise.resolve(this.data);
    }

    // don't have the data yet
    return new Promise((resolve,reject) => {
      // We're using Angular Http provider to request the data,
      // then on the response it'll map the JSON data to a parsed JS object.
      // Next we process the data and resolve the promise with the new data.
      this.http.get('https://randomuser.me/api/?results=1000')
        .map(res => res.json())
        .subscribe(data => {
          // we've got back the raw data, now generate the core schedule data
          // and save the data for later reference
          this.data = data.results;
          resolve(this.data);
        },err => {
            
            reject(err);
        });
    });
  }
}

Complete Code:


#4

Have you tried to open the page in incognito mode (Extensions are switched off then)? Or with a lower limit (10 instead of 1000)?


#5

Yesterday, I tried with lower limit and then it worked and Today it works even for the higher limit. What could be the cause of this issues?


#6

Are the .subscribe()only called once when all data are received or can it be called with chunk of data?
I am wondering this because why else would there be a need for a “complete” callback - the last one.

.subscribe(data=> {
},
(err)=> {
},
() => { // Complete
});