import React, { useState } from "react"; import CircularProgress from "@mui/material/CircularProgress"; import Button from "@mui/material/Button"; import TextField from "@mui/material/TextField"; import Typography from "@mui/material/Typography"; import Box from "@mui/material/Box"; import { mixFetch } from "@nymproject/mix-fetch-full-fat"; import Stack from "@mui/material/Stack"; import Paper from "@mui/material/Paper"; import type { SetupMixFetchOps } from "@nymproject/mix-fetch-full-fat"; const defaultUrl = "https://nymtech.net/.wellknown/network-requester/exit-policy.txt"; const args = { mode: "unsafe-ignore-cors" }; const mixFetchOptions: SetupMixFetchOps = { preferredGateway: "q2A2cbooyC16YJzvdYaSMH9X3cSiieZNtfBr8cE8Fi1", mixFetchOverride: { requestTimeoutMs: 60_000, }, forceTls: true, // force WSS }; export const MixFetch = () => { const [url, setUrl] = useState(defaultUrl); const [html, setHtml] = useState(); const [busy, setBusy] = useState(false); const handleFetch = async () => { try { setBusy(true); setHtml(undefined); const response = await mixFetch(url, args, mixFetchOptions); console.log(response); const resHtml = await response.text(); setHtml(resHtml); } catch (err) { console.log(err); } finally { setBusy(false); } }; return (
setUrl(e.target.value)} /> {busy && ( )} {html && ( <> Response {html} )}
); };