1.0.3 • Published 5 months ago

https-from-http v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

https-from-http

šŸš€ Convert HTTP requests to HTTPS automatically using a lightweight proxy.
Works like axios but without requiring axios locally!

✨ Features

āœ… Convert HTTP requests to HTTPS
āœ… Works like axios (get, post, put, remove, etc.)
āœ… No need to install axios
āœ… Lightweight & zero dependencies


šŸ“¦ Installation

npm install https-from-http
# OR
yarn add https-from-http
# OR
pnpm add https-from-http

šŸš€ Usage

1ļøāƒ£ GET Request

const callapi = require("https-from-http");

async function fetchData() {
  try {
    const response = await callapi.get("http://example.com");
    console.log("Response:", response);
  } catch (error) {
    console.error("Error:", error.message);
  }
}

fetchData();

2ļøāƒ£ POST Request with JSON Body

const callapi = require("https-from-http");

async function sendData() {
  try {
    const response = await callapi.post("http://example.com/api", {
      key: "value",
    });
    console.log("Response:", response);
  } catch (error) {
    console.error("Error:", error.message);
  }
}

sendData();

3ļøāƒ£ GET Request with Custom Headers

const callapi = require("https-from-http");

async function fetchWithHeaders() {
  try {
    const response = await callapi.get("http://example.com/api", {
      headers: { "User-Agent": "https-from-http" },
    });
    console.log("Response:", response);
  } catch (error) {
    console.error("Error:", error.message);
  }
}

fetchWithHeaders();

4ļøāƒ£ Using request() for Custom Requests

const callapi = require("https-from-http");

async function customRequest() {
  try {
    const response = await callapi.request({
      url: "http://example.com/api",
      method: "PUT",
      headers: { "Content-Type": "application/json" },
      data: { update: "test" },
    });
    console.log("Response:", response);
  } catch (error) {
    console.error("Error:", error.message);
  }
}

customRequest();

šŸ›  Methods Available

MethodDescription
.get(url, config?)Perform a GET request
.post(url, data, config?)Perform a POST request
.put(url, data, config?)Perform a PUT request
.patch(url, data, config?)Perform a PATCH request
.remove(url, config?)Perform a DELETE request
.request(config)Fully customizable request like axios
1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago