MCPcopy
hub / github.com/vercel/next.js / fetchStyleSheet

Function fetchStyleSheet

packages/next/src/client/route-loader.ts:274–294  ·  view source on GitHub ↗
(href: string)

Source from the content-addressed store, hash-verified

272 }
273
274 function fetchStyleSheet(href: string): Promise<RouteStyleSheet> {
275 let prom: Promise<RouteStyleSheet> | undefined = styleSheets.get(href)
276 if (prom) {
277 return prom
278 }
279
280 styleSheets.set(
281 href,
282 (prom = fetch(href, { credentials: 'same-origin' })
283 .then((res) => {
284 if (!res.ok) {
285 throw new Error(`Failed to load stylesheet: ${href}`)
286 }
287 return res.text().then((text) => ({ href: href, content: text }))
288 })
289 .catch((err) => {
290 throw markAssetError(err)
291 }))
292 )
293 return prom
294 }
295
296 return {
297 whenEntrypoint(route: string) {

Callers

nothing calls this directly

Calls 7

markAssetErrorFunction · 0.85
thenMethod · 0.80
getMethod · 0.65
setMethod · 0.65
textMethod · 0.65
fetchFunction · 0.50
catchMethod · 0.45

Tested by

no test coverage detected