خرید بک لینک

Vote count: 0

I'm trying to retu information from my api but I don't understand how to correctly use subscribe. With an array I retu an empty array from my service and push values into it as I get them.

How would I correctly retu just a single value variable in app-component ts. Right now If I do a alert(JSON.stringify(authenticated)) it just gives me {"_isUnsubscribed":false,"_subscriptions":[{"isUnsubscribed":false}]}

app-component ts

checkAuthentication(){
  var authenticated = this._authService.getAuthenication();
}

authentication Service

 getAuthenication() {
      retu this._http.get('auth.php').subscribe(res => {
        if (res.json().authenticated === true){
          retu true;
        }
        retu false;
      });
  }

auth.php

<?
session_start();
$authenticated = ( isset($_SESSION["authenticated"]) ? true : false );
$post_data = json_encode(array(authenticated => $authenticated));
echo $post_data;
?>

asked 38 secs ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: شنبه 1 اسفند 1394 ساعت: 20:31

صفحه بندی