Учитывая следующий упрощенный код, я не могу получить доступ к apollo
внутри then
.
logIn(context, { apollo, form }) {
return signInMutation({ apollo, ...form }).then((response) => {
apollo // undefined
});
});
Я пытаюсь получить доступ к apollo.provider
в следующем коде. Что сводит меня с ума, так это то, что logOut
работает без проблем, но logIn
дает мне эту ошибку.
vue-apollo.esm.js:1402 Uncaught (in promise) TypeError: Cannot read property '$apolloProvider' of null
at DollarApollo.get (vue-apollo.esm.js:1402)
at usersStore.js:46
Полный код
const actions = {
logOut(context, apollo) {
return signOutMutation({ apollo })
.then(response => response.data)
.then(response => {
if(_get(response, 'signOut.success', false)) {
localStorage.setItem(AUTH_TOKEN_KEY, '');
context.commit('clearUser');
return apollo.provider.clients.defaultClient.resetStore();
}
});
},
logIn(context, { apollo, form }) {
return signInMutation({ apollo, ...form })
.then(response => response.data)
.then(response => {
if(_get(response, 'signIn.success', false)) {
const user = _get(response, 'signIn.user', {});
localStorage.setItem(AUTH_TOKEN_KEY, user.authenticationToken);
context.commit('logIn', user);
return apollo.provider.clients.defaultClient.resetStore(); // line 46
}
});
},
};