Quentin
Quentin
Explore posts from servers
NNuxt
Created by Quentin on 9/4/2024 in #❓・help
Dependencies optimizations in dev mode
No description
2 replies
NNovu
Created by Quentin on 8/7/2024 in #💬│support
fetchUnreadCount capped at 100
Hi guys, i'm using headless on vuejs, and when i call fetchUnreadCount, it always returns 100 when i got more than 100 unread notifications. So i would like to know if there's a way to get the full number of unread notifications
6 replies
NNuxt
Created by Quentin on 8/1/2023 in #❓・help
useFetch update my data without assignment
Hi guys, I must have missed something, but I found something weird using useFetch. It looks like there's a kind of link between requests on the same URL. Here's my code for an example:
<script setup>
/**
* API fetch
*
* @param {String} url
* @param {Object} options
* @returns {Object}
*/
const fetch = (url, options) => {
return useFetch(url, {
baseURL: apiUrl(),
headers: {
accept: 'application/json',
'X-XSRF-TOKEN': useCookie('XSRF-TOKEN').value,
},
credentials: 'include',
...options,
})
}

// Get a json object { test: 'get' }
const { data: test } = await fetch('v1/test');

const post = () => {
// Get a json object { test: 'post' }
fetch('v1/test', { method: 'POST' });
};
</script>

<template>
Test: {{ test }}
<input type="button" value="Click me" @click="post"/>
</template>
<script setup>
/**
* API fetch
*
* @param {String} url
* @param {Object} options
* @returns {Object}
*/
const fetch = (url, options) => {
return useFetch(url, {
baseURL: apiUrl(),
headers: {
accept: 'application/json',
'X-XSRF-TOKEN': useCookie('XSRF-TOKEN').value,
},
credentials: 'include',
...options,
})
}

// Get a json object { test: 'get' }
const { data: test } = await fetch('v1/test');

const post = () => {
// Get a json object { test: 'post' }
fetch('v1/test', { method: 'POST' });
};
</script>

<template>
Test: {{ test }}
<input type="button" value="Click me" @click="post"/>
</template>
On the first load, my page shows Test: { "test": "get" }, that is what I wanted to do, fine. But when I click on the button, the page shows Test: { "test": "post" } and I don't understand why. I expected to see Test: { "test": "get" } again, as I didn't change the test variable by myself. Any idea? Thanks
4 replies
NNuxt
Created by Quentin on 6/23/2023 in #❓・help
Nuxt3 : Redirect in script setup
Hi guys, I'm requesting my API in my setup, and i want to redirect to a page and stop the rest of the setup when it returns me an error. I'm using navigateTo, it's working but the console shows me errors of undefined properties on the variable i set with my API response
const { data } = await useFetch('......', {
onResponse: ({response}) => {
if (! response.ok) {
return navigateTo(.....)
}
}
});

const myVar = ref(data.value.myVar); // this one throw me an error
const { data } = await useFetch('......', {
onResponse: ({response}) => {
if (! response.ok) {
return navigateTo(.....)
}
}
});

const myVar = ref(data.value.myVar); // this one throw me an error
7 replies