Skip to content

Instantly share code, notes, and snippets.

@laosb
Created August 13, 2017 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laosb/63016ac99f14a792350f3e3d809663ec to your computer and use it in GitHub Desktop.
Save laosb/63016ac99f14a792350f3e3d809663ec to your computer and use it in GitHub Desktop.
How we connect to backend accounts system on Nuxt.js
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