How does an Ionic application connect to a server?

Asked

Viewed 92 times

-1

Creating a Mobile Client/Server Calculator



I already created the app in Ionic, but how do I play the url of that server in my code? From what I understand, I have to import an HTTP API, and install a Provider... But how does this?

1 answer

0

Friend, it’s very simple. Just import the Native Http library from Ionic and make the requisitions to the required server. Ionic Documentation

Example:

import { HTTP } from '@ionic-native/http';

constructor(private http: HTTP) {}
this.http.get('http://enderecoservidor.io', {}, {})
  .then(data => {

    console.log(data.status);
    console.log(data.data); // data received by server
    console.log(data.headers);

  })

Browser other questions tagged

You are not signed in. Login or sign up in order to post.