私はVue.jsをVue-Apolloと使用しており、ユーザーにサインインするためにユーザーの突然変異を開始しています。私はgraph.coolサービスを使用しています。Vue.jsでApollo変異のエラーをユーザーに表示しますか?
私は無効な電子メールのようないくつかのエラーを捕まえるためのリクエストパイプライン機能のセットアップを持っています。
悪い/無効な入力が要求された場合、私のエラーcatch()
が(期待通りに)起動し、ネットワークのタブにカスタムエラーメッセージのJSONが表示されます。しかし、エラーがgraph.coolからトリガされた場合、どのようにこれらのエラー/レスポンスにキャッチ内からアクセスできますか?
例:
signin() {
const email = this.email
const password = this.password
this.$apollo.mutate({
mutation: signinMutation,
variables: {
email,
password
}
})
.then((data) => {
// This never fires on an error, so I can't
// show the user the errors in the network repsonse.
console.log(data)
})
.catch((error) => {
// Error in this part fires in the console
// but I'm unable to show the JSON response
// errors because the 'then()' above doesn't execute.
console.error(error)
})
}
私は認識されていないユーザーのために、次のエラーを取得:
Error: GraphQL error: No user found with that information at new ApolloError (eval at (app.js:956), :34:28) at eval (eval at (app.js:1353), :139:33) at
任意のアイデアはどのようにcatch()
内から応答でエラーを表示するには?
私は、文字通り、私はここでネットワーク]タブ上の応答でユーザに表示するエラーを表示することができます
...しかし、私はそれを行う方法を見つけ出すことはできません。
ご迷惑をおかけして申し訳ありません。ありがとうございました。
私はあなたが '.catch'の後ろに' .then'を追加することができると思います:https://stackoverflow.com/questions/35999072/what-is-the-equivalent-of-bluebird-promise-finally-in- native-es6-promises – thanksd
それは本当ですが、私は実際の応答自体に「データ」を保持することはできません。 :( –