Pinia bug? Report
Vue version
3.3.4
Link to minimal reproduction
Steps to reproduce
build actions in userStore.js like actions: { setUser_id(user_id) { this.user_id = user_id; }, setNickname(nickname) { this.nickname = nickname; }, setEmail(email) { this.email = email; }, setAddress(address) { this.address = address; }, setLevel(level) { this.level = level; }, setAgreement(agreement) { this.agreement = agreement; }, setReg_date(reg_date) { this.reg_date = reg_date; }, async start(phone_number) {
try {
const response = await axios.post('user/', {
phone_number: phone_number,
user_id: this.user_id
});
console.log(response.data);
this.user_id = response.data.user_id;
this.nickname = response.data.nickname;
this.email = response.data.email;
this.address = response.data.address;
this.level = response.data.level;
this.agreement = response.data.agreement;
this.reg_date = response.data.reg_date;
router.push({ name: 'UserProfile', params: { user_id: this.user_id }});
} catch (err) {
console.log(err);
}
},
async login(phone_number) {
try{
const response = await axios.post('login/', {
phone_number: phone_number,
});
console.log(response.data);
this.user_id = response.data.user_id;
this.nickname = response.data.nickname;
this.email = response.data.email;
this.address = response.data.address;
this.level = response.data.level;
this.agreement = response.data.agreement;
this.reg_date = response.data.reg_date;
router.push({ name: 'MainPage'});
} catch (err) {
console.log(err);
}
}
},
AND in export default,
setup() { const phone_number = ref(""); const userStore = useUserStore();
return { phone_number, userStore };
},
methods: { startUsingStore() { this.userStore.start(this.phone_number); },
startLogin() {
this.userStore.login(this.phone_number);
},
}.
when click startLogin, not startUsingStore, this happens.
What is expected?
Login with only phone_number. (using Query)
What is actually happening?
cannot proceed because of need of parameter that caused by startUsingStore method which is not been clicked.
System Info
No response
Any additional comments?
No response
export const useUserStore = defineStore('user', {
state: () => {
return {
userId: null,
};
},
});
const store = useStore();
store.userId = 'foo';
If you think Pinia has a bug, please provide feedback at https://github.com/vuejs/pinia. If it's a usage question, please ask in the GitHub discussions. Additionally, we need minimal reproduction.