Skip to content

Instantly share code, notes, and snippets.

@avblink
Last active July 11, 2017 08:08
Show Gist options
  • Save avblink/933761a4ddf79181137c209adb8213b1 to your computer and use it in GitHub Desktop.
Save avblink/933761a4ddf79181137c209adb8213b1 to your computer and use it in GitHub Desktop.
Vue and Nuxt related snippets

Add sass loader

npm install node-sass sass-loader --save-dev

NUXT simultaneous asynchronous data request

async asyncData({ params }) {
  let [users, posts] = await Promise.all([
    axios.get('http://jsonplaceholder.typicode.com/users'),
    axios.get('http://jsonplaceholder.typicode.com/posts')
  ])

  return {
    users: users.data,
    posts: posts.data
  }
}

Don't forget to install and import axios:

npm install axios --save
import axios from 'axios'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment