# About the @ionic-native/http/ngx

**URL:** <https://forum.ionicframework.com/t/about-the-ionic-native-http-ngx/182905>\
**Category:** Ionic Framework\
**Created:** [February 7, 2020, 9:51am UTC](https://forum.ionicframework.com/t/about-the-ionic-native-http-ngx/182905 "2020-02-07T09:51:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![innamnv](https://avatars.discourse-cdn.com/v4/letter/i/87869e/32.png) [@innamnv](https://forum.ionicframework.com/u/innamnv)\
**Post date:** [February 7, 2020, 9:51am UTC](https://forum.ionicframework.com/t/about-the-ionic-native-http-ngx/182905/1 "2020-02-07T09:51:22Z")

</div>

I want to make a post request by this library because when i post by @angular/common/http, it is have error that CROS. I dont know why and i try to use @ionic-native/http/ngx. But i have a error that Object(…) is not a function. Please help me. I make a project alone and deadline is comming ☹

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [February 7, 2020, 7:34pm UTC](https://forum.ionicframework.com/t/about-the-ionic-native-http-ngx/182905/2 "2020-02-07T19:34:24Z")

</div>

CORS really really needs to be dealt with on the server. If you don’t control the server, ask whoever does to deal with this.

---

<div class="post-metadata">

**Author:** ![ncarlin](https://avatars.discourse-cdn.com/v4/letter/n/71c47a/32.png) [@ncarlin](https://forum.ionicframework.com/u/ncarlin)\
**Post date:** [February 8, 2020, 4:05pm UTC](https://forum.ionicframework.com/t/about-the-ionic-native-http-ngx/182905/3 "2020-02-08T16:05:24Z")

</div>

Could you post an example of how you are implementing the native HTTP package? Here is what my post function looks like.

```auto
  post(endpoint: string, body: any, token?: string) {
    const headers = this.createHeaders(token);
    if (this.hasCordova) {
      this.httpNat.setDataSerializer('json');
      return from(this.httpNat.post(this.apiUrl + '/' + endpoint, body, null).then(response => {
          return JSON.parse(response.data);
        }).catch(error => {
          console.log(error.status);
          console.log(error.error);
          console.log(error.headers);
        }));
    } else {
    return this.http.post(this.apiUrl + '/' + endpoint, body, { headers });
    }
  }

```

---

<div class="post-metadata">

**Author:** ![innamnv](https://avatars.discourse-cdn.com/v4/letter/i/87869e/32.png) [@innamnv](https://forum.ionicframework.com/u/innamnv)\
**Post date:** [February 9, 2020, 3:06pm UTC](https://forum.ionicframework.com/t/about-the-ionic-native-http-ngx/182905/4 "2020-02-09T15:06:37Z")

</div>

i think the reason is how did i send post request. They have a sample by PHP. I test by it. it is ok. But when i coded by ionic. It is CROS

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [February 9, 2020, 10:24pm UTC](https://forum.ionicframework.com/t/about-the-ionic-native-http-ngx/182905/5 "2020-02-09T22:24:56Z")

</div>

> [@innamnv](#):
>
> i think the reason is how did i send post request

OK then. I’m not going to force you to listen to me.

---

<div class="post-metadata">

**Author:** ![innamnv](https://avatars.discourse-cdn.com/v4/letter/i/87869e/32.png) [@innamnv](https://forum.ionicframework.com/u/innamnv)\
**Post date:** [February 10, 2020, 1:40am UTC](https://forum.ionicframework.com/t/about-the-ionic-native-http-ngx/182905/6 "2020-02-10T01:40:10Z")

</div>

> **[HTTP - Ionic Documentation](https://ionicframework.com/docs/native/http)**
>
> Ionic is the app platform for web developers. Build amazing mobile, web, and desktop apps all with one shared code base and open web standards

  
i follow by this link. Sorry Because i reply late. But my bug is not done ☹

---

<div class="post-metadata">

**Author:** ![sanjay100](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sanjay100/32/130599_2.png) [@sanjay100](https://forum.ionicframework.com/u/sanjay100)\
**Post date:** [February 11, 2020, 2:20pm UTC](https://forum.ionicframework.com/t/about-the-ionic-native-http-ngx/182905/7 "2020-02-11T14:20:21Z")

</div>

First install  
npm install --save @angular/common/http

i have created one function called login() with http

code:

import { HttpClient } from ‘@angular/common/http’;

export class LoginPage implements OnInit {

films : any;  
constructor(public httpClient: HttpClient) {  
}  
login(mobile)  
{  
this.films = this.httpClient.get(“[https://yoururl/foldername/myfile.php?mobile=](https://yoururl/foldername/myfile.php?mobile=)”+mobile);  
this.films.subscribe(data =\> {  
console.log(data);  
});  
}  
}
