This project is part of the Vuex Crash Course on YouTube
npm install
npm run serve
npm run build
npm run test
npm run lint
Vuex crah course app
The await is causing a delay when deleting, removing the await fixes it. Which should be fine with current implementation. Although might not work in a production environment.
async deleteTodo({ commit }, id) { axios.delete(
https://jsonplaceholder.typicode.com/todos/${id}`);
commit('removeTodo', id);
}`
@bradtraversy Thank you for your tutorial.
This is really helping lot. I am stuck at this point. Could you please assist me?
I am unable to update my recipeArray after inserting data to Firestore.
I am using nuxt framework
store/recipes.js
export const state = () => ({
recipesList: [] //***This gets updated using action fetchRecipes action and used on index page
})
export const getters = {
// There is no use of this at this point of time
}
export const actions = {
async addRecipe({ commit }, title) {
const response = this.$fireStore.collection('recipes')
try {
await response
.add({
title: title,
slug: title,
publish: true,
created: new Date()
})
.then(res => {
// eslint-disable-next-line no-console
console.log('Added document with ID: ', res.id) //**This is printing data on console
commit('addRecipe', res) //** This mutation call is where I am having issue, looks like firestore needs a separate call to get the data, can i have async call inside another async? also res does not have the required data in it to be added to recipeArray
})
} catch (e) {
console.log(e)
alert(e)
return
}
alert('Success.')
},
async fetchRecipes({ commit }) {
const recipeArray = []
const response = this.$fireStore.collection('recipes')
try {
await response
.where('publish', '==', true)
.orderBy('created', 'desc')
.get()
.then(querySnapshot => {
querySnapshot.forEach(doc => {
recipeArray.push(doc.data())
})
})
commit('setRecipes', recipeArray)
} catch (e) {
// alert(e)
alert('Error Fetching Data, please contact Webmaster')
}
}
}
export const mutations = {
setRecipes: (state, recipesList) => (state.recipesList = recipesList),
addRecipe: (state, recipe) => state.recipesList.unshift(recipe)
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.