@sammycolson wrote:
i can’t access to a key of a json response from a restful web service.
{"_body":"{\"values\": {\"user_id\":\"1\",\"name\":\"fred test\",\"email\":\"fred@test.test\",\"username\":\"fredtest\",\"token\":\"d5f66a06ec809d70d0c52842df8dc0011d7d1ad0f2d56f50d3123da17a2489fe\"}}","status":200,"ok":true,"statusText":"OK","headers":{"pragma":["no-cache"],"content-type":["text/html;charset=UTF-8"],"cache-control":["no-store"," no-cache"," must-revalidate"],"expires":["Thu"," 19 Nov 1981 08:52:00 GMT"]},"type":2,"url":"http://localhost/PHP-Slim-Restful/api/login"}
I would like to acces to ‘values’ in this function: (this.responseData.values)
login(){ console.log('login'+ this.userData); // Your app login API web service call triggers this.authService.postData(this.userData,'login').then((result) => { this.responseData = result; console.log('userdata : '+ temp); if(this.responseData.values){ console.log('response: ' + this.responseData); localStorage.setItem('userData', JSON.stringify(this.responseData)); this.navCtrl.push(TabsPage); } else{ this.showToastWithCloseButton() } }, (err) => { console.log('erreur : '+err); }); }
I have an error undifined!
Can you help me?
Posts: 6
Participants: 2