Functionsfetcherfetcher Callablefetcher<JSON>(input: RequestInfo, init?: RequestInit): Promise<JSON>Performs a fetch operation and returns the response data as JSON. Throws an error if the response is not successful (HTTP status code other than 2xx).@example// Perform a fetch request to retrieve JSON datafetcher<Data>("https://api.example.com/data", { method: "GET" }) .then(data => { console.log("Data:", data); }) .catch(error => { console.error("Error:", error); });Type parametersJSON = anyThe type of the JSON response data.
Performs a fetch operation and returns the response data as JSON. Throws an error if the response is not successful (HTTP status code other than 2xx).