In vue.js. I have the following auth.js, at the bottom of the js file it has "export default". In my Registration.vue file how do I access "actions"?
This is what I have tried:
Registration.vue
import {actions} from 'src/util/auth';
export default {
components: {
actions
},
data(){
},
methods: {
submitReg() {
console.log(actions)
}
}
}
error: export 'actions' was not found in 'src/util/auth'
This is the auth.js file full code here https://gist.github.com/toricls/5c38d2930a36262f0674c1ffa8d5134a:
import Amplify, { Auth } from 'aws-amplify';
const state = {
user: null,
};
const actions = {
async getCurrentUserInfo({ commit }) {
// This is returning null - why?
// const user = await Auth.currentUserInfo();
const user = await Auth.currentAuthenticatedUser();
const attributes = await Auth.userAttributes(user);
console.log(attributes);
commit(types.AUTHENTICATE, {
username: user.username,
...extractAttributes(attributes),
});
},
async signIn({ commit }, { username, password }) {
const user = await Auth.signIn(username, password);
const attributes = await Auth.userAttributes(user);
commit(types.AUTHENTICATE, {
username: user.username,
...extractAttributes(attributes),
});
},
async signOut() {
await Auth.signOut();
},
async signUp(_, { username, password, firstName, lastName }) {
const data = await Auth.signUp({
username,
password,
attributes: {
given_name: firstName,
family_name: lastName,
},
});
console.log(data);
},
};
const mutations = {
[types.AUTHENTICATE](state, payload) {
state.user = payload;
},
[types.SIGNOUT](state) {
state.user = null;
},
};
export default {
namespaced: true,
state,
actions,
mutations,
};