feature: create POST api done.

This commit is contained in:
Cindy Chang
2024-06-21 15:21:24 +08:00
parent 0fb0d8b529
commit 9b0d54bf5e
4 changed files with 109 additions and 13 deletions

View File

@@ -69,6 +69,28 @@ export default defineStore('acctMgmtStore', {
isEditHovered: false,
}));
},
/**
* Create new user in database.
* @param {object} userToCreate
* userToCreate {
* "username": "string",
* "password": "string",
* "name": "string",
* "is_admin": boolean,
* "is_active": boolean,
* }
*/
async createNewAccount(userToCreate) {
const apiCreateAccount = `/api/users`;
try{
const response = await this.$axios.post(apiCreateAccount, userToCreate);
console.log('TODO: response:', response, response.status);
}
catch(error) {
apiError(error, 'Failed to add a new account');
};
},
/**
* According to mouseover or mouseleave status, change the bool value.
* @param {string} username