Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to set the request to POST or GET. #28

Merged
merged 1 commit into from
Dec 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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