Cannot call web service with parameter


#1

Hello guys, I’m trying to cal a web service with some paremters.
in home.ts file i’ve this list of params

var params = {
                  service: this.toBase64('register'),
                  device_id: this.toBase64(this.device.uuid),
                  org_name: this.toBase64(this.orgName),
                  org_email: this.toBase64(this.orgMail),
                  org_address: this.toBase64(this.orgAddress),
                  org_boardnumber: this.toBase64(this.boardNumber),
                  org_password: this.toBase64(this.password),
                  org_phone: this.toBase64(this.orgPhone)
        }

             this.regProvider.postRequest(params)
           .subscribe(response => console.log(response))

there is method postRequest() in Provider there is file register.ts. Here is method implementation.

postRequest(params) {
        var headers = new Headers();
        headers.append("Accept", 'application/json');
        headers.append('Content-Type', 'application/json' );
        headers.append('Access-Control-Allow-Origin', '*' );
     
        let options = new RequestOptions({ headers: headers });
     let jsonData = JSON.stringify(params)
    
    return  this.http.post(this.baseUrl, jsonData, options)
          .map(response => response.json());
      }

when i run application. this error appears

Screen Shot 2017-11-21 at 12.38.59 PM.png

Can anyone help me where i made mistake.Thanks


#2

You have hit the CORS wall…

adding Access-Control-Allow-Origin to the client side call is useless. it is a server side header.

either you use Native HTTP plugin or you setup a proxy


#3

Access-Control-Allow-Origin is added to server side, still i was getting that error.
I tried native HTTP but got this error

No provider for Http!
imageerror.png