Skip to content

Commit

Permalink
feat: allow customizing http method for user endpoint (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
cesaramirez authored and pi0 committed Dec 28, 2017
1 parent 1b8856c commit 994152b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
endpoint: 'auth/user',
propertyName: 'user',
resetOnFail: true,
enabled: true
enabled: true,
method: 'GET',
},
login: {
endpoint: 'auth/login',
Expand Down Expand Up @@ -60,6 +61,7 @@ Sets the global settings for store **fetch** action.
* **endpoint** - Set the URL of the user data endpoint. It can be a relative or absolute path.
* **propertyName** - Set the name of the return object property that contains the user data. If you want the entire object returned, set an empty string.
* **resetOnFail** - Automatically invalidate all tokens if user fetch fails. (Default is `true`)
* **method** - Set the request to POST or GET.
#### login
Set the global settings for store **login** action.
Expand Down
3 changes: 2 additions & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module.exports = function (moduleOptions) {
endpoint: 'auth/user',
propertyName: 'user',
resetOnFail: true,
enabled: true
enabled: true,
method: 'GET'
},
login: {
endpoint: 'auth/login',
Expand Down
2 changes: 1 addition & 1 deletion lib/templates/auth.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default {

// Try to get user profile
try {
const data = await this.$axios.$get(endpoint)
const data = await this.$axios.$<%= options.user.method.toLowerCase() %>(endpoint)
commit('SET_USER', data<%= options.user.propertyName ? ('[\'' + options.user.propertyName + '\']') : '' %>)
} catch (e) {
console.error(e)
Expand Down

0 comments on commit 994152b

Please sign in to comment.