Comment on page
Quasar/Vuejs/Firebase
npm i -g @quasar/cli@latest
The best approach is to use Firestore directly in the app without a nodejs backend for most things. Vuexfire seems to be a good candidate to abstract a lot of hassle away for this.
methods: {
getPosts() {
this.$axios
.get(`${process.env.API}/posts`, {
headers: { Authorization: this.$q.localStorage.getItem("token") },
})
.then((resp) => {
this.posts = resp.data;
})
.catch((error) => {
if (error.response) {
if (error.response.status == 403) {
this.$q.localStorage.remove("loggedIn");
this.$q.localStorage.remove("token");
this.$router.push("/auth").catch((err) => {console.log(err)});
}
}
});
},
When commiting to git, include
.postcssrc.js
manually or the quasar app will break.A more elegant way to write asynchronous functions without using .then and .catch is this format:
const funcName = async() => {
const a = getA()
const b = getB()
const c = await Promise.all([a,b])
return c
}
You could also await getA() and getB() separately, but they would not execute in parallel like in the example. This is useful if the value of B depends on A.
Last modified 9mo ago