0

ionic 3 http.post or get methods fired twice my code as below

this.httpService.post(this.APIs.getPGs, { userId: id }, result => {
    console.log("test");
    this.httpService.hideLoading();
    if (result.statusCode) {
      callback(result.data);
    } else {
      this.httpService.showAlert(result.message);
      callback(false);
    }
  });

when i serve my results i see it fired twice as image :

getOwnerPG fired twice

Ionic Framework: 3.6.0

Ionic App Scripts: 2.1.3

Angular Core: 4.1.3

Angular Compiler CLI: 4.1.3

Node: 6.11.3

OS Platform: OS X El Capitan

Navigator Platform: MacIntel

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6)

AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36

any solutions ?

Ahmed ElShemy
  • 66
  • 1
  • 10
  • where is the callback function coming from? It's not defined anywhere. – Johannes Klauß Jan 15 '18 at 14:19
  • Are you sure this isn't [a preflight issue](https://stackoverflow.com/questions/1256593/why-am-i-getting-an-options-request-instead-of-a-get-request)? E.g. one is for HTTP OPTIONS, the other is your actual HTTP POST. This isn't clear from your screenshot. – Juliën Jan 15 '18 at 14:26
  • No its not both requests POST – Ahmed ElShemy Jan 16 '18 at 23:02

0 Answers0