Download next.js/packages/next/src/experimental/testmode/httpget.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 577 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/experimental/testmode/httpget.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/experimental/testmode/httpget.ts
-
curl -L -o httpget.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/experimental/testmode/httpget.ts
577 Bytes
| import { ClientRequestInterceptor } from 'next/dist/compiled/@mswjs/interceptors/ClientRequest' | |
| import { handleFetch } from './fetch' | |
| type Fetch = typeof fetch | |
| export function interceptHttpGet(originalFetch: Fetch): () => void { | |
| const clientRequestInterceptor = new ClientRequestInterceptor() | |
| clientRequestInterceptor.on('request', async ({ request }) => { | |
| const response = await handleFetch(originalFetch, request) | |
| request.respondWith(response) | |
| }) | |
| clientRequestInterceptor.apply() | |
| // Cleanup. | |
| return () => { | |
| clientRequestInterceptor.dispose() | |
| } | |
| } | |