\n \u003C/NuxtLayout>\n \u003C/UApp>\n\u003C/template>\n\u003Cscript setup lang=\"ts\">\nimport { fr, en } from '@nuxt/ui/locale';\nconst locales = { fr, en };\nconst { t, locale } = useI18n();\n\u003C/script>\n```\nAnalyze your bundle:\n`npx nuxi analyze`\n\n### Description\n\nAs you can see, unused locales are still included in the bundle, while only Fr and En have been imported\n\n\n\n### Additional context\n\n_No response_\n\n### Logs\n\n```shell-script\n\n```",[3180,3183],{"name":3181,"color":3182},"bug","d73a4a",{"name":3184,"color":3185},"v3","49DCB8",3602,"ui","i18n, Unused locales are included in the bundle","2025-03-18T14:19:38Z","https://github.com/nuxt/ui/issues/3602",0.635407,{"description":3193,"labels":3194,"number":3198,"owner":3146,"repository":3146,"state":3172,"title":3199,"updated_at":3200,"url":3201,"score":3202},"Some of my projects want to retrieve data for the first time when entering a request, and then make judgments. Every time I retrieve the data, I judge the value obtained, but he always cannot judge it normally. It seems that even after I wait, the data he retrieves seems to be asynchronous,\n\n```\nconst {data} = useFetch(\"url\")\nif(data.value.Code===1){\n\n\n\n}\n```",[3195],{"name":3196,"color":3197},"pending triage","E99695",32624,"Has anyone found any bugs in useFetch?","2025-07-16T16:08:49Z","https://github.com/nuxt/nuxt/issues/32624",0.65820473,{"description":3204,"labels":3205,"number":3210,"owner":3146,"repository":3146,"state":3172,"title":3211,"updated_at":3212,"url":3213,"score":3214},"### Environment\n\n------------------------------\n- Operating System: Linux\n- Node Version: v22.3.0\n- Nuxt Version: 3.17.5\n- CLI Version: 3.25.1\n- Nitro Version: 2.11.12\n- Package Manager: pnpm@9.15.4\n- Builder: -\n- User Config: compatibilityDate, devtools, future, vite, modules, css, runtimeConfig\n- Runtime Modules: @nuxt/ui@3.1.3, nuxt-svgo@4.2.2, @nuxt/image@1.10.0\n- Build Modules: -\n------------------------------\n\n### Reproduction\n\n```ts\n\u003Cscript setup lang=\"ts\">\nconst page = useState('movie-page', () => 1)\nconst data = useState\u003CMovie[]>('movie-data', () => [])\n\nconst { pending, execute } = await useFetch\u003CListResponse\u003CMovie>>('/api/tmdb/discover/movie', {\n query: {\n page,\n },\n async onResponse({ response }) {\n data.value.push(...response._data.results)\n },\n immediate: false,\n})\n\nif (data.value.length === 0)\n execute()\n\nconst pageContainer = useTemplateRef('pageContainer')\n\nonMounted(() => {\n const scrollContainer = document.getElementById('scrollContainer')\n scrollContainer?.addEventListener('scroll', () => {\n if (!pending.value && pageContainer.value && window.innerHeight + 1000 > pageContainer.value?.getBoundingClientRect().bottom) {\n page.value++\n }\n })\n})\n\u003C/script>\n```\n\n### Describe the bug\n\nI want to create an infinite scrollable page. To do so, I need to store the received data of `useFetch` in an array.\nSince I want to be able to navigate to another page and go back, without refetching all data, I use `useState`.\n\nHowever, when navigating back, `useFetch` would trigger again (with previous page value) if I use `immediate: true.` Therefore `immediate: false` is set and we manually call execute to fetch data on first page load.\n\nin the scroll listener, `page++` is called. The strange thing is:\n* On first page load, this is enough to retrigger fetching data. Not needing to call `execute()` manually.\n* Once navigated away and returning to the page, the `page` value is increased by the event listener (so still working), but `useFetch` does not trigger anymore.\n\n### Additional context\n\n_No response_\n\n### Logs\n\n```shell-script\n\n```",[3206,3207],{"name":3196,"color":3197},{"name":3208,"color":3209},"needs reproduction","FBCA04",32467,"inconsistent behaviour useFetch","2025-06-24T21:21:12Z","https://github.com/nuxt/nuxt/issues/32467",0.66800576,{"description":3216,"labels":3217,"number":3220,"owner":3146,"repository":3171,"state":3172,"title":3221,"updated_at":3222,"url":3223,"score":3224},"\n",[3218],{"name":3181,"color":3219},"ff281a",522,"Checkboxes broken on dark mode","2022-05-23T15:16:45Z","https://github.com/nuxt/nuxt.com/issues/522",0.67663306,{"description":3226,"labels":3227,"number":3220,"owner":3146,"repository":3159,"state":3172,"title":3232,"updated_at":3233,"url":3234,"score":3224},"Hey I was using `mockNuxtImport` to mock 2 different users from a nuxt composable in the same test file. It seems to use the last `mockNuxtImport` that is called in the file, not the one scoped to the test.\r\n\r\n```ts\r\nit('renders the users email', () => {\r\n\tmockNuxtImport('useSupabaseUser', () => {\r\n\t\treturn () => mockUser\r\n\t})\r\n\r\n\trender(User)\r\n\r\n\texpect(screen.getByText('jdoe@gmail.com')).toBeInTheDocument()\r\n})\r\n\r\nit('renders the Error when there is no user', () => {\r\n\tmockNuxtImport('useSupabaseUser', () => {\r\n\t\treturn () => {}\r\n\t})\r\n\r\n\trender(User)\r\n\r\n\texpect(screen.getByText('Error')).toBeInTheDocument()\r\n})\r\n```\r\n\r\nThe first test fails here as it thinks `useSupabaseUser` returns {}\r\n\r\nI did manage to get this working with a global variable:\r\n\r\n```ts\r\nlet mockUser = { id: 1, name: 'John Doe', email: 'jdoe@gmail.com' }\r\n\r\nmockNuxtImport('useSupabaseUser', () => {\r\n\treturn () => mockUser\r\n})\r\n\r\nit('renders the users email', () => {\r\n\trender(User)\r\n\r\n\texpect(screen.getByText('jdoe@gmail.com')).toBeInTheDocument()\r\n})\r\n\r\nit('renders the Error when there is no user', () => {\r\n\tmockUser = {}\r\n\r\n\trender(User)\r\n\r\n\texpect(screen.getByText('Error')).toBeInTheDocument()\r\n})\r\n```\r\n\r\nNot really sure if this is expected, it seems a little strange to me, so figured I post my findings.",[3228,3231],{"name":3229,"color":3230},"documentation","0075ca",{"name":3157,"color":3158},"Mocking multiple iterations of nuxt imports in the same test file","2024-01-24T12:25:29Z","https://github.com/nuxt/test-utils/issues/522",{"description":3236,"labels":3237,"number":3239,"owner":3146,"repository":3146,"state":3172,"title":3240,"updated_at":3241,"url":3242,"score":3243},"### Describe the feature\n\nIn applications with authentication, it's often the case that fetched data can vary depending on whether the user is logged in or has specific permissions.\n\nThere can be endpoints that are only accessible to authenticated users or those with the required permissions. In this case, the fetch should ideally be executed only when the conditions are met.\n\nIt gets more complex when the fetch conditions are changing (such as during login / logout), where I usually re-fetch async data using `refreshNuxtData()`. Re-execution can also happen due to changes in watched values, etc.\n\nUsing the `immediate` option as a workaround works for the initial fetch but doesn't solve anything for `refreshNuxtData()`, and may execute requests that shouldn't have been.\n\nExample:\n\n```ts\nconst { data } = useFetch('/api/something-protected', {\n immediate: isLoggedIn.value\n})\n```\n\nTo address this, I would like to propose a new `execute` hook. This would be evaluated before each execution of the async data handler, and if it returns a falsy value, the request would be skipped.\n\nExample:\n\n```ts\nconst { data } = useFetch('/api/something-protected', {\n execute: () => isLoggedIn.value\n})\n```\n\nFeedback or alternative suggestions on this approach would be appreciated. 🙏 As far as known, there is currently no easy way to achieve this.\n\n### Additional information\n\n- [x] Would you be willing to help implement this feature?\n- [ ] Could this feature be implemented as a module?\n\n### Final checks\n\n- [x] Read the [contribution guide](https://nuxt.com/docs/community/contribution).\n- [x] Check existing [discussions](https://github.com/nuxt/nuxt/discussions) and [issues](https://github.com/nuxt/nuxt/issues).",[3238],{"name":3196,"color":3197},33022,"`execute` hook in `useAsyncData` to determine if fetch should run","2025-08-21T12:21:08Z","https://github.com/nuxt/nuxt/issues/33022",0.6774278,{"description":3245,"labels":3246,"number":3251,"owner":3146,"repository":3146,"state":3172,"title":3252,"updated_at":3253,"url":3254,"score":3255},"### Environment\r\n\r\nNuxt project info: 10:45:42\r\n\r\n------------------------------\r\n- Operating System: Windows_NT\r\n- Node Version: v16.15.1\r\n- Nuxt Version: 3.6.1\r\n- Nitro Version: 2.5.2\r\n- Package Manager: npm@8.11.0\r\n- Builder: vite\r\n- User Config: pages\r\n- Runtime Modules: -\r\n- Build Modules: -\r\n\r\n### Reproduction\r\n\r\n```javascript\r\n\u003Cscript setup>\r\n/**\r\n * 请求api接口\r\n * @returns {Promise\u003Cany>}\r\n */\r\nconst getData = async () => {\r\n const { data, pending, error, refresh } = await useFetch('/api/test', {\r\n onResponse({ request, response, options }) {\r\n // 处理响应数据\r\n // localStorage.setItem('token', response._data.token)\r\n console.log(\"响应成功数据:\", response);\r\n }\r\n })\r\n\r\n console.log(\"data:\", data);\r\n}\r\n\r\nonMounted(() => {\r\n getData()\r\n})\r\n\u003C/script>\r\n\r\n```\r\n\r\n### Describe the bug\r\n\r\n### 标题:在 Nuxt 3.0 中,useFetch 的 onResponse 在 onMounted 中无法被执行\r\n\r\n### 描述:\r\n\r\n在我使用 Nuxt 3.0 的 useFetch 功能时,我发现了一个问题。如果我在 onMounted 的生命周期钩子中调用 useFetch,onResponse 似乎无法获取结果,或者说 onResponse 方法没有被执行。然而,如果我直接在 setup 中调用 useFetch,onResponse 就会被执行。这是我的代码:\r\n\r\n```javascript\r\n\u003Cscript setup>\r\n/**\r\n * 请求api接口\r\n * @returns {Promise\u003Cany>}\r\n */\r\nconst getData = async () => {\r\n const { data, pending, error, refresh } = await useFetch('/api/test', {\r\n onResponse({ request, response, options }) {\r\n // 处理响应数据\r\n // localStorage.setItem('token', response._data.token)\r\n console.log(\"响应成功数据:\", response);\r\n }\r\n })\r\n\r\n console.log(\"data:\", data);\r\n}\r\n\r\nonMounted(() => {\r\n getData()\r\n})\r\n\u003C/script>\r\n```\r\n### 重现步骤:\r\n\r\n1. 创建一个新的 Nuxt 3.0 项目。\r\n2. 在 onMounted 的生命周期钩子中调用 useFetch。\r\n3. 观察控制台,无法看到 \"响应成功数据\" 的日志输出。\r\n\r\n**期望的行为:**\r\nonResponse 在 onMounted 中被正确执行,并在控制台输出 \"响应成功数据\"。\r\n\r\n**实际的行为:**\r\nonResponse 在 onMounted 中没有被执行。\r\n\r\n**环境信息:**\r\nNuxt.js 版本:3.0\r\n浏览器版本:Firefox 116.0.3 (64 位)\r\n操作系统:Windows 11\r\nNode.js 版本:16.15.1\r\n\r\n**附加信息:**\r\n我尝试在 setup 中直接调用 useFetch,这时 onResponse 可以被正确执行。\r\n\r\n\r\n\r\n*****\r\n\r\n\r\n\r\n\r\n### Title: In Nuxt 3.0, useFetch's onResponse is not executed in onMounted\r\n\r\n### Description:\r\n\r\nWhile using the useFetch feature in Nuxt 3.0, I encountered a problem. If I call useFetch in the onMounted lifecycle hook, onResponse seems unable to obtain a result, or in other words, the onResponse method is not executed. However, if I call useFetch directly in setup, onResponse is executed. Here is my code:\r\n\r\n```javascript\r\n\u003Cscript setup>\r\n/**\r\n * Request API interface\r\n * @returns {Promise\u003Cany>}\r\n */\r\nconst getData = async () => {\r\n const { data, pending, error, refresh } = await useFetch('/api/test', {\r\n onResponse({ request, response, options }) {\r\n // Processing response data\r\n // localStorage.setItem('token', response._data.token)\r\n console.log(\"Successful response data:\", response);\r\n }\r\n })\r\n\r\n console.log(\"data:\", data);\r\n}\r\n\r\nonMounted(() => {\r\n getData()\r\n})\r\n\u003C/script>\r\n```\r\n### Steps to reproduce:\r\nCreate a new Nuxt 3.0 project.\r\nCall useFetch in the onMounted lifecycle hook.\r\nObserve the console, the \"Successful response data\" log output is not visible.\r\n\r\n### Expected behavior:\r\nonResponse is correctly executed in onMounted, and \"Successful response data\" is output to the console.\r\n\r\n### Actual behavior:\r\nonResponse is not executed in onMounted.\r\n\r\n### Environment Information:\r\nNuxt.js version: 3.0\r\nBrowser version: Firefox 116.0.3 (64-bit)\r\nOperating System: Windows 11\r\nNode.js version: 16.15.1\r\n\r\n### Additional Information:\r\nWhen I try to call useFetch directly in setup, onResponse is correctly executed.\r\n\r\n### Additional context\r\n\r\n完整代码如下(The complete code is as follows):\r\n``` vue\r\n\u003C!-- index.vue -->\r\n\u003Ctemplate>\r\n \u003Cdiv>\r\n \u003Ch1>欢迎来到我的首页\u003C/h1>\r\n \u003C/div>\r\n\u003C/template>\r\n\r\n\u003Cscript setup>\r\n/**\r\n * 请求api接口\r\n * @returns {Promise\u003Cany>}\r\n */\r\nconst getData = async () => {\r\n const { data, pending, error, refresh } = await useFetch('/api/test', {\r\n onResponse({ request, response, options }) {\r\n // 处理响应数据\r\n // localStorage.setItem('token', response._data.token)\r\n console.log(\"响应成功数据:\", response);\r\n }\r\n })\r\n\r\n console.log(\"data:\", data);\r\n}\r\n\r\nonMounted(() => {\r\n getData()\r\n})\r\n\r\n\r\n\u003C/script>\r\n\r\n\u003Cstyle scoped>\u003C/style> \r\n``` \r\n\r\n\r\n### Logs\r\n\r\n_No response_",[3247,3250],{"name":3248,"color":3249},"3.x","29bc7f",{"name":3196,"color":3197},22688,"在 Nuxt 3.0 中,useFetch 的 onResponse 在 onMounted 中无法被执行","2023-12-29T08:03:51Z","https://github.com/nuxt/nuxt/issues/22688",0.67971367,["Reactive",3257],{},["Set"],["ShallowReactive",3260],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$f8eSm9KdRbsTs95ldLc3QtQj9zVPog_VCp1asV4jVYIU":-1},"/nuxt/test-utils/611"]