Created
August 13, 2017 10:27
-
-
Save laosb/63016ac99f14a792350f3e3d809663ec to your computer and use it in GitHub Desktop.
How we connect to backend accounts system on Nuxt.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
export default { | |
methods: { | |
async login() { | |
const data = await axios.post('https://example.com/api/login', { | |
username: this.$refs.username.value, | |
password: this.$refs.password.value | |
}) | |
if (!data.err) { | |
const currentUser = await axios.get('https://example.com/api/user/current') | |
this.$store.commit('SET_USER', currentUser) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment