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


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? 


use promise. a simple exmaple here it is;

    return new Promise((resolve, reject) => {
            this.http.get(url, options )
                .map(res => res.json())
                      data => this.list = data,
                      err => {console.error('There was an error: ' + err);
                      () => {
                        // console.log(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