特定のキーの特定の値を取得しようとしています。私のJSONオブジェクトは、コンソールから直接取ったものです。JSON.parse get value
0
:
{mail: "[email protected]", location: "England", about: "Rockstar", phoneNr: "1233425"}
応答を取得し、
getProfile(){
const obs = new Subject<Users[]>();
this.http.post('http://localhost/shareVideoAppPHP/sharevideoapp-backend/readProfile.php', "1", {headers: this.headers})
.subscribe((message) => { //Function data
const response = JSON.parse(message.text());
obs.next(response);
console.log("Mesage------->", response);
}, (error) => {
console.log("Error from server!", error);
});
}
が、私はそれらのすべては、以下の印刷与える
response.location
response["location"]
message["location"]
message.location
を試してみたと存じそれを印刷しマイ角度コード:これは最後のものを除いMesage-------> undefined
をエラーを通知します
ありがとう、これはいくつかの変更を加えて機能しました。最終コードは でした。 'response.profile [0] .location' – Fig