Http methods called twice

Hello everyone,
I’m new at framework and I have the following code inside a provider.

searchSpeaker(searchParam: string): Observable<Speaker[]> {
    var json = JSON.stringify({ search: searchParam});
    var params = json;
    var headers = new Headers();
    headers.append('Content-Type', 'application/json');
    return this.http.post(`${this.url}${this.f}`,params,{headers:headers})
      .map(res => <Speaker[]>res.json());
    }

Everything working fine, but when i opened the developer tool, it triggered twice.


First One:

Second One:

I searched the web but i couldnt solve the problem. And one more thing, my system information

Cordova CLI: Not installed
Ionic Framework Version: 3.0.0
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.0
ios-deploy version: 1.9.1 
ios-sim version: 5.0.13 
OS: macOS Sierra
Node Version: v6.10.2
Xcode version: Xcode 8.3.2 Build version 8E2002

Any ideas???

:smiley: The first one is an options call, the second one is the actual post. Nothing to worry about, just a common cross-domain pattern.

1 Like

Yeah you are right it was just a stupid mistake :grin:
just changed the Content-Type to application/x-www-form-urlencoded and it worked
thank you :slight_smile:

Are you sure that the problem was the Contet-Type?
Beacuse I can see from this post that " OPTIONS requests are what we call pre-flight requests in Cross-origin resource sharing (CORS)`".

I’ve the same problem and changing the Content-Type doesn’t help.

cld