lav
Explore posts from serversClient-Side Middleware
Hello, I was wondering if it is possible to have a middleware runs only client-side and redirect if something is not set for example in local storage, etc.
Right now I am doing this test and I return if it is server let's say I have to access local storage, but I still see the test page beign render and after it redirects is there a way to fix this? Thanks!
1 replies
Middleare for Auth
Hello, I was wondering what is the best way to verify if user is logged in before showing route, I am doing a basic test right now via localStorage variable in real life I would have my state in local storage or global store saying i am logged in with an http cookie.
Is there a way so the user is not even able to see the other page before the redirect?
21 replies
[useAsyncData] Component is already mounted, please use $fetch instead. See
Why do I have component already mounted?
I want to use useAsyncData, to get the status to see if it is pending or success to render a loading state, how can I?
I've use useAsyncData in my composables that I directly call in my setup, do I have to make my own loading and use $fetch directly since useAsyncData needs to be call in the setup?
Thanks!
3 replies
Shadcn Library
Is there any library build on top of shadcn that works with vue?
https://awesome-shadcn-ui.vercel.app/
I use shadcn-vue but I've seen beautiful stuff from aceternity UI for example with nice background effect and stuff, lemme know if you know this for vue. ty
1 replies
UseState with a state coming from a db
Hello, I've issue with reactive state for useState, I fetch players from a DB and place them into the global state, but the components getting the global state are not updating to get the version that is coming from client side rendering when i load the page from another page.
This is my composables that I use in parent:
I've tried using my useState in my computed prop it didnt work either.
I retrieve it like so in child:
I am pretty new to vue/nuxt sorry.
I do not know if this is a good way to use the global store either
Each component are children of each other so I could've done prop drilling or injection. I think it would be a better fit ig, but I wanna know if what I want to do is possible
10 replies
State not changing when using a composables
Hello, my component was not updating when I changed player id using a composables when I placed this directly in component it was working but as composables it wasn't:
import { ref, computed } from 'vue';
import { throws } from '~/data/baseball';
export function usePlayerData(players, playerId) {
const selectedPlayer = computed(() => {
if (playerId === null) {
return null;
}
return players.find((player) => player.id == playerId);
});
const selectedThrows = computed(() => {
if (selectedPlayer.value === null) {
return null;
}
return throws.filter((shot) => shot.player_id === selectedPlayer.value.id);
});
return { selectedPlayer, selectedThrows };
}
So this is now my composables and in my component:
const props = defineProps({
playerId: {
required: true,
},
});
const { value: players } = useState('players');
const { selectedPlayer, selectedThrows } = usePlayerData(
players,
props.playerId
);
This was not working anyone knows why?
This works tho:
Composables:
import { ref, computed } from 'vue';
import { throws } from '~/data/baseball';
export function usePlayerData(players, playerId) {
const selectedPlayer = computed(() => {
if (playerId.value === null) {
return null;
}
return players.find((player) => player.id == playerId.value);
});
const selectedThrows = computed(() => {
if (selectedPlayer.value === null) {
return null;
}
return throws.filter((shot) => shot.player_id === selectedPlayer.value.id);
});
return { selectedPlayer, selectedThrows };
}
Component:
const props = defineProps({
playerId: {
required: true,
},
});
const reactivePlayerId = ref(props.playerId);
watch(
() => props.playerId,
(newPlayerId) => {
reactivePlayerId.value = newPlayerId;
}
);
const { selectedPlayer, selectedThrows } = usePlayerData(
players,
reactivePlayerId
);
I used a watch for my ref
13 replies
Repository patern backend & disadvantage backend in another directory
Hello, I was wondering if it is possible to inject a class instance in my backend.
I would like to make the repository pattern and basically inject my class like we do in the frontend but in the backend. I could not figure out so if if anyone know, please tell me.
Also, is there a disadvantage of moving the backend to another project using express or something at the place of using server directory?
7 replies
Railway hobby plan
Hello, I just got hobby's plan.
I was wondering if the 5$ took would be taken every months or it is just taken because I started the plan?
Also, is there a way to put a limit of 5$ so I never go higher than 5$ and stay in the hobby plan if anything goes bad?
19 replies
TTCTheo's Typesafe Cult
•Created by lav on 5/8/2023 in #questions
What are the down side of using docker?
I was wondering the down side of using docker, I've never heard theo opinion on docker.
I would love to hear y'all opinions on it. I am brand new to docker.
12 replies