Kuroro
Kuroro
NNuxt
Created by Tom on 6/10/2024 in #❓・help
Preventing Refetching in Component
didn't see it was already answered! nice ❤️
6 replies
NNuxt
Created by Furnaxe on 4/30/2024 in #❓・help
UPagination
Nice 👍🏻
11 replies
NNuxt
Created by Furnaxe on 4/30/2024 in #❓・help
UPagination
Did you try this ? I think useFetch is waiting for the reactive part of your variable page You don't need to use watch() when you're using useFetch because it's already looking for changes in his options (included params)
const { data: yachtsData, error } = useFetch(
'/api/yachts/getAllYachts', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
params: {
page,
},
});
const { data: yachtsData, error } = useFetch(
'/api/yachts/getAllYachts', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
params: {
page,
},
});
If you want to continue with a watch solution, ensure the watch is triggered by logging something (and be sure that there's no warn/error logs)
11 replies
NNuxt
Created by Jonathan on 3/4/2024 in #❓・help
search page dont work
ok im gonna try something on a stackblitz repro then, will tell you soon
44 replies
NNuxt
Created by Jonathan on 3/4/2024 in #❓・help
search page dont work
i think we need to know your wanted behavior My guess is : - You can init the page with searched results through your query like : http://myurl.com?search=blablabla - Each time you're writing something in the search bar, it triggers again a fetch method, and write the search result in the URL query part : - So, if you type "product1" in the search bar - Your query URL will be : http://myurl.com?search=product1
44 replies
NNuxt
Created by Jonathan on 3/4/2024 in #❓・help
search page dont work
you don't have to create a tricky behavior to do this
44 replies
NNuxt
Created by Jonathan on 3/4/2024 in #❓・help
search page dont work
give me a reproduction on stackblitz
44 replies
NNuxt
Created by Jonathan on 3/4/2024 in #❓・help
search page dont work
Remove .get
44 replies
NNuxt
Created by Jonathan on 3/4/2024 in #❓・help
search page dont work
Your second capture ! You still use /api/search.get
44 replies
NNuxt
Created by Jonathan on 3/4/2024 in #❓・help
search page dont work
you also should add console.log to your [...search].get.ts in order to see if you reach the endpoint (you would be able to determine your issue about your wrong API path if u had it before)
44 replies
NNuxt
Created by Jonathan on 3/4/2024 in #❓・help
search page dont work
<script setup>
const { q } = useRoute().query;

const { data: allProducts } = await useFetch("/api/search", {
query: { q }
});
</script>
<script setup>
const { q } = useRoute().query;

const { data: allProducts } = await useFetch("/api/search", {
query: { q }
});
</script>
You don't have to specify ".get" in "/api/search.get" If you want to specify the method (- not needed when it's GET request because its the default value) :
const { data: allProducts } = await useFetch("/api/search", {
method: 'GET',
query: { q }
});
const { data: allProducts } = await useFetch("/api/search", {
method: 'GET',
query: { q }
});
it should work now
44 replies
NNuxt
Created by Jonathan on 3/4/2024 in #❓・help
search page dont work
You can come back to your previous version (with useFetch)
44 replies
NNuxt
Created by Jonathan on 3/4/2024 in #❓・help
search page dont work
just made a typo (i forgot to delete your allProducts ref)
44 replies
NNuxt
Created by Victor Neves on 3/4/2024 in #❓・help
server middleware added to nuxt config
Hi, I think there's no needed anymore You just have to try to remove it and add some logs into your middleware, to see if it's actually working, no?
3 replies
NNuxt
Created by Jonathan on 3/4/2024 in #❓・help
search page dont work
Hi, trying to help :
<script setup>
const { q } = useRoute().query;

const { data: allProducts } = await useFetch("/api/search.get", {
query: { q }
});
</script>
<script setup>
const { q } = useRoute().query;

const { data: allProducts } = await useFetch("/api/search.get", {
query: { q }
});
</script>
You don't have to add an extra "watch" method because useFetch is already listening through options obj
44 replies
NNuxt
Created by Kuroro on 2/27/2024 in #❓・help
Differents watch sources using useState
As you can see in screenshots, IDE is not really explicit... maybe should I log them to see further
36 replies
NNuxt
Created by Kuroro on 2/27/2024 in #❓・help
Differents watch sources using useState
No description
36 replies
NNuxt
Created by Kuroro on 2/27/2024 in #❓・help
Differents watch sources using useState
Ahah thanks! That's the first time I see this kind of trick. It wouldn't be the best case in my opinion, because we're obliged to define each property of the object into different variables, It feels a bit hacky no? Anyway, thanks for your time As I said in my repro, I got it working too, but, i'm really looking for a technical explanation & why not, have an advice on the best way to go ! 🙂
36 replies
NNuxt
Created by Kuroro on 2/27/2024 in #❓・help
Differents watch sources using useState
Oh ok, I probably shouldn't do assignation here... Strapi API returns an object with two keys, trying to deal with it without wrapping my useAsyncData in a function... maybe should I ? there's a minimal repro with a dummy API, but it reproduces my behavior : https://stackblitz.com/edit/nuxt-starter-cicj7t?file=components%2FTodosTable.vue See comments in TodosTable.vue 🙂
36 replies
NNuxt
Created by Kuroro on 2/27/2024 in #❓・help
Differents watch sources using useState
It's not. I'm maybe wrong, but i think useState is already returning a Ref, so i don't get it when you talk about specifying a ref/reactive in useState (make it nosense for me, but, once again, i'm maybe wrong) And, if you find the docs page where it's specified, i would be happy to see it.
36 replies