Package Exports
- util-http
- util-http/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (util-http) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
util-http
util-http es un módulo de utilidades para realizar solicitudes HTTP con diversas opciones y clientes.!
⚠ ADVERTENCIA:
Asegúrate de configurar correctamente las opciones del cliente antes de realizar solicitudes.
Clientes disponibles
Ejemplo
Aquí tienes un ejemplo de cómo puedes realizar solicitudes utilizando los clientes proporcionados.
import { AxiosClient, FetchClient, UndiciClient, HttpClient } from "util-http";
const axiosClient = new AxiosClient();
const fetchClient = new FetchClient();
const undiciClient = new UndiciClient();
const httpClient = HttpClient.getInstance();
// Ejemplo de solicitud GET con AxiosClient
axiosClient.get({ url: "https://api.example.com/data" }).then(console.log).catch(console.error);
// Ejemplo de solicitud POST con FetchClient
fetchClient
.post({
url: "https://api.example.com/data",
data: { key: "value" },
headers: { "Content-Type": "application/json" }
})
.then(console.log)
.catch(console.error);
// Ejemplo de solicitud GET con UndiciClient
undiciClient.get({ url: "https://api.example.com/data" }).then(console.log).catch(console.error);
// Ejemplo de solicitud GET con HttpClient usando Axios
httpClient.axios.get({ url: "https://api.example.com/data" }).then(console.log).catch(console.error);
// Ejemplo de solicitud POST con HttpClient usando Fetch
httpClient.fetch
.post({
url: "https://api.example.com/data",
data: { key: "value" },
headers: { "Content-Type": "application/json" }
})
.then(console.log)
.catch(console.error);
// Ejemplo de solicitud GET con HttpClient usando Undici
httpClient.undici.get({ url: "https://api.example.com/data" }).then(console.log).catch(console.error);Uso de los clientes
AxiosClient
ℹ DESCRIPCIÓN:
Cliente basado en Axios para realizar solicitudes HTTP.
FetchClient
ℹ DESCRIPCIÓN:
Cliente basado en Fetch API para realizar solicitudes HTTP.
UndiciClient
ℹ DESCRIPCIÓN:
Cliente basado en Undici para realizar solicitudes HTTP de alto rendimiento.
HttpClient
ℹ DESCRIPCIÓN:
Cliente genérico para realizar solicitudes HTTP.
