Custom Get Response from Api

i created form and input data to get custom respon from api and after that i test to display in console log but i get undifined in the console log and in my form i got message [Object Object].The API work well when i used manually input in the uri (url/?id=myid&code=mycode).Help me to solve this problem. Thanks before.

Here is the code

Api.php

`$code=$this->input->get(‘code’);
$id= $this->input->get(‘id’);
$x=$this->GetOne($id);
foreach($x as $y){
$finalis=$y[‘nama’];
}

    $a=$this->PeriksaKode($code);
    $n=$this->GetOneCode($code);
    foreach ($n as $value) {
        $vote=$value['vote'];
    }
    if($a===TRUE){
        $this->UpdateCode($code, $id, $vote);
        $json[] = array(
            'pesan'=>"THis is the message when the condition is true"
        );
    }else{
        $json[]=array(
            'pesan'=>"False message"
        );
    }
    echo json_encode($json);`

Service
`import { Injectable } from ‘@angular/core’;
import { Http } from ‘@angular/http’;
import ‘rxjs/add/operator/map’;

@Injectable()
export class KodeService {
data: any;
id:any;
kode:any;
apiUrl = ‘http://localhost/BGKadmin/index.php/BGKSS/Api/Kode’;
constructor(private http: Http) {
this.data = null;
}

load(id, kode) {
if (this.data) {
return Promise.resolve(this.data);
}

return new Promise(resolve => {

  this.http.get(this.apiUrl + "/?id=" + this.id + "&"+"code=" + this.kode)
    .map(res => res.json())
    .subscribe(data => {
      this.data = data;
      resolve(this.data);
    });
});

}
}

`

vote.ts
`import { Component } from ‘@angular/core’;
import { NavController, NavParams } from ‘ionic-angular’;
import {KodeService} from ‘…/…/providers/kode-service/kode-service’;

@Component({
templateUrl: ‘build/pages/vote/vote.html’,
providers: [KodeService]
})
export class VotePage {
satu;
kode:any;
pesan:any;
constructor(private nav: NavController, public param: NavParams, private kodeService: KodeService) {
this.satu = param.get(‘satu’);

}
submit(){
this.kodeService.load(this.satu.id , this.kode).then(data=> {
this.pesan =data;
});
console.log(this.pesan);
}
}
`

vote.html
` <ion-navbar *navbar favorite>
Vote

<ion-content padding class="vote">
    <ion-card>
        <ion-card-header>
            Vote to : {{satu.nama}}
        </ion-card-header>
        <ion-card-content>
            <center>Enter the code</center>
            <ion-input type="text" placeholder="XXX" [(ngModel)]="kode" ></ion-input>
            <button (click)="submit()">submit</button>
        </ion-card-content>
    </ion-card>
</ion-content>

`

Assuming that UpdateCode modifies some sort of database, and that this API is designed to be casting votes, you should be using POST instead of GET. GET handlers must be idempotent and may not modify visible state. If seven GET requests to the same URI result in seven votes being cast, your design is broken.

thanks for answer. and i updated my code. But i get some error

vote.ts
`import { Component } from ‘@angular/core’;
import { NavController, NavParams } from ‘ionic-angular’;
import {KodeService} from ‘…/…/providers/kode-service/kode-service’;
import { Http } from ‘@angular/http’;

@Component({
templateUrl: ‘build/pages/vote/vote.html’,
providers: [KodeService]
})
export class VotePage {
satu;
kode:any;
pesan:any;
data:any;

constructor(private nav: NavController, public param: NavParams, private kodeService: KodeService, public http:Http) {
this.satu = param.get(‘satu’);
this.kode.id =’’;
this.kode.satu=’’;
}
submit(){
let link = ‘http://localhost/BGKadmin/index.php/BGKSS/Api/Kode’;
let data = JSON.stringify({id: this.kode.id, kode:this.kode.satu});
this.http.post(link, data)
.subscribe(data =>{
this.data.response = data._body;
console.log(this.data.response);
},error =>{
console.log(‘Oooops!’);
});
}
}
api.phppublic function Kode(){
$postdata = file_get_contents(“php://input”);
$request = json_decode($postdata);
$code=$request->code;

    $id=  $request->id;
    $x=$this->GetOne($id);
    foreach($x as $y){
        $finalis=$y['nama'];
    }

    $a=$this->PeriksaKode($code);
    $n=$this->GetOneCode($code);
    foreach ($n as $value) {
        $vote=$value['vote'];
    }
    if($a===TRUE){
        $this->UpdateCode($code, $id, $vote);
        echo "$vote vote untuk $finalis berhasil ditambahkan";
    }else{
        echo "Maaf Kode yang anda masukkan salah";
    }
}`

vote.html
`<ion-navbar *navbar favorite>
Vote

<ion-content padding class="vote">
    <ion-card>
        <ion-card-header>
            Vote untuk : {{satu.nama}}
        </ion-card-header>
        <ion-card-content>
            <center>Masukkan kode anda</center>
            <ion-row text-center>
                <ion-input type="text" placeholder="XXX" [(ngModel)]="kode.satu" ></ion-input>
                <ion-input type="text" placeholder="XXX" ></ion-input>
                 <ion-input type="text" placeholder="XXX" ></ion-input>
            </ion-row>
            <input type="hidden" [(ngModel)]="kode.id" value="{{satu.id}}">
            <button (click)="submit()">Masukkan</button>
        </ion-card-content>
    </ion-card>
</ion-content>

`

error message
TypeScript error: D:/xampp/htdocs/BGK/app/pages/vote/vote.ts(26,30): Error TS2341: Property ‘_body’ is private and only accessible within class ‘Response’.

Try data.text () or data.json ()

thank you very much all… it helps me…