Permalink
Browse files

feat: allow customizing http method for user endpoint (#28)

  • Loading branch information...
cesaramirez authored and pi0 committed Dec 28, 2017
1 parent 1b8856c commit 994152b2c3f33c51b9ea2e6abe20889a567fac08
Showing with 6 additions and 3 deletions.
  1. +3 −1 README.md
  2. +2 −1 lib/module.js
  3. +1 −1 lib/templates/auth.store.js
@@ -29,7 +29,8 @@
endpoint: 'auth/user',
propertyName: 'user',
resetOnFail: true,
enabled: true
enabled: true,
method: 'GET',
},
login: {
endpoint: 'auth/login',
@@ -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.
@@ -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',
@@ -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)

0 comments on commit 994152b

Please sign in to comment.