When a Vue detail page first opens, why does Network show two records for the same API when I only wrote one onMounted?
When the same API appears twice on the first screen of a Vue page, in most cases it is not a backend retry and not a browser preflight, but non-unique data-fetching entry points: watch immediate and onMounted each send one request, or route param changes, keep-alive activated, or parent component prop passing triggers another round. For the handling order, first check the initiator call stack of the two requests in the Network panel to confirm whether it is dual entry points or parameter churn, then converge data fetching into one function and one trigger point. In 2026 projects, this kind of problem appears more often on detail pages and list filter pages.
1. Conclusion first: for two first-screen records, check the data-fetching entry point before suspecting API retries
In the development environment, one extra request usually means only one extra log line, so it is easy to ignore. In a real 2026 project, one extra request affects backend API call volume, per-call third-party service cost, and the counting basis for PV and impressions in tracking at the same time. On high-frequency entry points such as list pages and detail pages, once the duplication rate rises, API volume commonly increases by 30% to 50%, and in severe cases approaches doubling, rather than increasing only slightly.
The way to judge is fairly direct: open Network and check Preserve log, expand the initiator of the two requests. If they come from different functions, it is dual entry points; if they come from the same function, then check retries, preflight, or concurrency. Separating the chains before changing code can save a round of rework.
2. What duplicate requests cost: API volume, tracking, and state races
A duplicate request is not harmless just because it is one more call. On APIs billed per call or rate-limited, it amplifies both cost and failure probability; in tracking, once the impression and click base is inflated, the calculated conversion rate comes out lower; on the page, the two responses may return in any order, and older data arriving later can overwrite the newer result, so users see a flash and then it changes back.
- Inflated API volume: the same data is requested twice, cache hit rate drops, and gateway thresholds are easier to trigger.
- Distorted tracking: the impression and click base is inflated, and conversion rate definitions need extra correction.
- State races: the two responses may return in any order, an old response overwrites a new result, and the page jumps back.
- Regression cost: after release, tracing back from logs, rate-limit alerts, and tracking deviations commonly takes half a workday to two workdays.
The cost of duplicate first-screen requests is not only in writing code, but in troubleshooting, rollback, and regression; converging before integration is usually less troublesome than handling it after release.
3. Use the call stack to distinguish four trigger chains
The reason to separate the chains before changing code is that duplicate requests have different fixes: dual entry points need merged entry points, parameter churn needs stable references, and lifecycle overlap needs hooks moved. If you add debounce or request caching right away, it is easy to hide the second entry point, and it reappears on another page in the next version.
- Chain 1: watch immediate and onMounted coexist. Both places call the same data-fetching function, so the first screen is likely to send two requests.
- Chain 2: watch listens to an object or array literal. The parent component creates a new reference on every render, so the listener is triggered repeatedly.
- Chain 3: keep-alive activated overlaps with onMounted. On first entry both hooks run, and when returning to the list activated runs again.
- Chain 4: route param changes and the component watch respond at the same time. When switching id, the guard and the watch each send one request.
For locating the issue, we can use a fixed order, which we internally call the four-step call-stack tracing process:
- Check the call stack: in Network, check Preserve log, expand the initiator of the two requests, and confirm whether they come from different functions.
- Mark time points: add console.trace or a breakpoint on the first line of the suspicious function, and check the order and arguments of the two triggers.
- Subtract: temporarily comment out one chain and keep only one, then observe whether the request count returns to one.
- Then converge: after confirming the entry point, change the structure rather than suppressing the symptom with debounce, throttle, or request caching.
The third step is easy to skip, but it determines whether you are fixing the root cause or the symptom. By experience, cases that can be located to a specific function in about ten minutes are mostly dual entry points; cases that require switching pages back and forth to reproduce are often related to keep-alive or route reuse.
4. Converge data fetching to a single entry point and check these acceptance criteria
The core of convergence is just one sentence: for the same data source, only one function is responsible for initiating the request, and other places only call it. watch decides when to fetch, and onMounted no longer initiates again; parameter changes are passed in through watch arguments, rather than having two hooks each read the state. In this way, when filter conditions are added later, only one place needs to change.
- Extract one fetchList or fetchDetail: pass parameters explicitly, without relying on state scattered inside the component.
- Keep only one trigger point: if an initial value is needed, use watch with immediate; if the first screen should fetch only once, use onMounted as the single entry.
- Assign a sequence number to requests: use an auto-increment id or cancellation token to discard expired responses and avoid old data overwriting new data.
- Loading and empty states share the same source: set loading following the single entry point to reduce flicker caused by two requests.
It is recommended to write the acceptance criteria into the integration checklist: the API is sent only once on first entry; switching filters or paging sends one request each time with correct parameters; returning from detail to list refreshes once as needed, not every time; rapid clicks on a weak network do not cause stacked requests. If these are not met, do not rush to release; this kind of problem is much more obvious on real networks than locally.
In one delivery setting, we encountered an admin detail page: the constraints were a two-to-three-week schedule, an API with a QPS limit, and a page that needed to fetch by route id and also support in-page filters. The approach was to keep watch with immediate as the single entry point, delete the fetch in onMounted, merge filter conditions into the watch source, and add an auto-increment sequence number to requests to discard expired responses. The result was that the first screen went from two requests back to one, API volume dropped back, and integration was completed the same day; the cost was about an extra half day to regress returning to the list and rapid clicks on a weak network. Based on the experience range, handling this kind of issue before integration is commonly half an hour to two hours; after release, tracing it back from rate-limit alerts and tracking deviations commonly falls in the half-workday to two-workday range.
5. How to choose among approaches and which pages do not need this
There is no universal approach, only an approach that matches the dependency relationship. The criterion is: what does this data depend on—only component creation, route params, user actions, or a combination of multiple sources. The more dynamic the dependency, the more it should be handled by watch rather than piled into onMounted. A more common practice in 2026 is to determine the dependency source first and then choose the hook; if the order is reversed, it is easy to end up with two entry points.
- onMounted single entry: suitable for data fetched only once; the change scope is small, and the typical time before integration is half an hour to two hours; if watch is added later for filters, it is easy to return to dual entry points.
- watch with immediate single entry: suitable when data depends on route params or filter conditions; the typical time including regression is one hour to half a day; the watch source should be specific to fields, not an object literal directly.
- Request caching or debounce to suppress the symptom: typical time is within half an hour; but if the second entry point is not located, the probability of recurrence in later versions is higher, and regression cost may increase to more than half a workday.
- keep-alive activated refresh: suitable when returning to the list needs the latest data; it needs to be distinguished from first entry, and typical adjustment plus regression is about half a day each time; if the latest data is not needed, there is no need to force a refresh.
Applicable boundaries: detail pages that fetch by parameters, list pages with filters, and pages that reuse the same component with different ids are suitable for this method of converging entry points; purely static display pages, pages where the server has already injected data, and one-time validation requests for submit forms do not need to be forced onto it. Adding request caching or cancellation tokens to them only increases maintenance cost.
There is another boundary to distinguish: if duplicate requests come from backend retries, browser preflight, third-party scripts, or requests initiated by an SDK itself, front-end entry-point convergence cannot solve it. You should go back to server logs, network configuration, or script integration to troubleshoot. Do not treat every pair of two records as duplicate watch writes.
FAQ
In Vue, if watch has immediate, do I still need to call it again in onMounted?
Usually not. immediate executes once when the listener is established, so calling it again in onMounted easily creates dual entry points; keep one place and confirm the parameter source.
If the two requests have the same parameters and return normally, do I still need to change it?
It is recommended to change it. Same parameters do not mean no cost; API call volume, tracking base, and rate-limit thresholds are all affected; converging before integration is usually less troublesome than troubleshooting after release.
Can debounce or request caching directly cover up duplicate requests?
It can suppress the symptom, but it easily hides the second entry point. First check the call stack to confirm whether it is dual entry points, parameter churn, or lifecycle overlap, then decide whether to add caching or a cancellation token.
If a keep-alive page requests again when returning, does that count as duplication?
It depends on the business. If the latest data is needed, keep the activated refresh and make first entry go through only one entry point; if not, do not refresh, to avoid overlap with onMounted.
If the duplication comes from backend retries or browser preflight, should I still change it this way?
No. First check whether the initiator comes from a front-end function; when it comes from backend retries, preflight, or third-party scripts, troubleshoot on the server or in the script configuration. Front-end entry-point convergence cannot solve it.
-
If an API occasionally returns null and a product card prints “null,” should the fallback live in data fetching or rendering?
Date: Nov 22, 2026 Read: 8
-
In admin lists, when a product name gets long, the Edit/Unpublish button is pushed off screen—should the ellipsis go on the title or the outer container?
Date: Nov 21, 2026 Read: 8
-
In 2026, AI-generated pages work fine on the normal path, but what happens when the network drops, users click repeatedly, or they hit back? Are these edge states the frontend team's job?
Date: Nov 20, 2026 Read: 18
-
In 2026, product says only “make it a bit smoother” before a project starts—then brings up experience before launch. Who should kick off the experience target sheet?
Date: Nov 19, 2026 Read: 12
-
A coupon pop-up is still open in WeChat, but pressing Back on the phone exits the whole campaign page—who should own the Back button?
Date: Nov 18, 2026 Read: 20




