Skip to content

Instantly share code, notes, and snippets.

@bschulz87
Created May 23, 2018 13:56
Show Gist options
  • Save bschulz87/f05fabe041909e99a28e788e8901159c to your computer and use it in GitHub Desktop.
Save bschulz87/f05fabe041909e99a28e788e8901159c to your computer and use it in GitHub Desktop.
Vuex API Example
import api from '@/api'
const getArticle = ({commit}) => {
return new Promise((resolve, reject) => {
api.getArticle().then((result) => {
if (result) {
commit('UPDATE_ARTICLE', result)
resolve('Successfully got article')
} else {
reject(Error('Could not get article'))
}
})
})
}
export {
getArticle
}
import Parse from 'parse'
const Article = Parse.Object.extend('Article')
const getArticle = async () => {
const articleQuery = new Parse.Query(Article)
return await brandQuery.first().then((result) => {
return result
})
}
export {
getArticle
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment