2016-09-04 16 views
0

これは過去2日間頭痛を与えています。私は最近私のlaravelアプリケーションを5.3にアップデートしました。ローカル環境でLaravel/passportを取得しました。インストール後、すべて正常に動作します。Laravel 5.3 Passport - Vueエラー:式を評価する際のエラー

このアップデートをプロダクションサーバーにプッシュすると、すべての機能は引き続き動作しますが、vueはパスポートコンポーネントにエラーを表示します。私はまだ非常に新しいものであり、これを引き起こしているものは見つけられません。

私が最後に試したのは、同じエラーが発生するプロダクションサーバーにLaravelとパスポートを新しくインストールすることでした。このインストールをローカルマシンにプッシュすると、すべてが機能します。私はこれが何らかの依存エラーであると推測します。

これらはエラーです:

[Vue warn]: Error when evaluating expression "token.scopes.length > 0": TypeError: Cannot read property 'length' of undefined (found in component: <passport-authorized-clients>) 
[Vue warn]: Error when evaluating expression "token.client.name": TypeError: Cannot read property 'name' of undefined (found in component: <passport-authorized-clients>) 
[Vue warn]: Error when evaluating expression "token.scopes.length > 0": TypeError: Cannot read property 'length' of undefined (found in component: <passport-authorized-clients>) 
[Vue warn]: Error when evaluating expression "token.client.name": TypeError: Cannot read property 'name' of undefined (found in component: <passport-authorized-clients>) 

は、誰でも同じエラーに直面している、と私はこれをどのように修正するのですか?

編集:私はこれを修正することができました。私はphp5.6をphp7にアップデートし、以下のPHPモジュールをインストールしました。 libgmp-dev、php-gmp。私が再び新しくインストールしたとき、npmはパスポートが必要とする2つの不備について苦情を言いました。 mdanter/eccとindigophp/hash-compat

+0

ここにいくつかのより多くのコードが必要ですが、あなたは(少なくともinit'、 'に)存在しないいくつかの値をバインドしようとしているように思えます。空のオブジェクトとしてトークンを作成してから、さらにプロパティを追加しますか?作成時にこのプロパティにアクセスしようとする要素がありますか? –

+0

私はちょうどそれを考え出した。 OAuthサーバーが機能しないPHPモジュールがありましたが、なぜ 'composer require laravel/passport'が私にエラーを投げなかったのかわかりません。しかし、私がPHPモジュールをインストールした後、nodeは 'mdanter/eccとindigophp/hash-compat'が正しく機能するために必要な別のエラーを出しました。 –

+0

私はそれを見て、それはクライアントの問題[vuejs/vue-resource#317](https://github.com/vuejs/vue-resource/issues/317) –

答えて

1

私は同じ問題がありました。ソリューションhereが私を助けました。それはresources/assets/js/bootstrap.jsに以下を追加示唆:

Vue.http.interceptors.push((request, next) => { 
    next((response) => { 
     if('Content-Type' in response.headers 
      && response.headers['Content-Type'] == 'application/json'){ 
      if(typeof response.data != 'object'){ 
       response.data = JSON.parse(response.data); 
      } 
     } 

     if('content-type' in response.headers 
      && response.headers['content-type'] == 'application/json'){ 
      if(typeof response.data != 'object'){ 
       response.data = JSON.parse(response.data); 
      } 
     } 
    }); 
});