How to connect IONIC2 with ASP.NET MVC API Backend Services

Hi,

Currently i am working on creating REST API for Connecting Backend(Sqlserver) with Ionic2. So i have choosen ASP.NET MVC as a middle ware. it should have our business logic inorder to getting data from
server and the resulting data is converted to json format.

Once the fetching process finished ( middleware operations) finished then Ionic app will get the data from
json file using HTTP client…

 So, How can i achieve the above steps ? Any sample available for MVC API? 

Thanks,
Krupa.sharp

use promise. a simple exmaple here it is;

funcGetData(){
    return new Promise((resolve, reject) => {
            this.http.get(url, options )
                .map(res => res.json())
                .subscribe(
                      data => this.list = data,
                      err => {console.error('There was an error: ' + err);
                            reject(err.statusText);
                       },
                      () => {
                        // console.log(this.list);
                        resolve(this.list);
                      }
                );
        });
}

and import these;
import ‘rxjs/add/operator/map’;
import ‘rxjs/add/operator/toPromise’;
This works on Ionic 3, And it could work in IO3 too I believe.

1 Like