A light weight yet an efficient HTTPS module to make API requests
Https function to replace your good ol' node-fetch and axios.
const simply = require("simply-https");
simply.https("url", {
method: "GET", // required
// options (optional)
});
This returns a Promise so you should await it and should be located inside an
async
function. Or your project should be configured totop-level await
https(
url: string | httpsOptions,
options: httpsOptions = {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
}
): Promise<any>
-
url:
string
|httpsOptions
-
options:
httpsOptions
-
Resolves:
any
Just the https function but with "GET" method
const simply = require("simply-https");
simply.get("url", {
// options (optional)
});
Just the https function but with "POST" method
const simply = require("simply-https");
simply.post("url", {
// options (optional)
});
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
method |
'GET' /'POST' /'PUT' /'PATCH' /'DELETE' /'HEAD' /'CONNECT' /'OPTIONS' /'TRACE' |
❌ | "GET" | Provide a method to access the api |
headers |
HTTPHeaders | ❌ | { 'Content-Type': 'application/json' } | The header of the request |
body |
Object | ❌ | none | The body to send the request (cannot be used in 'GET' request) |
const simply = require("simply-https");
// should be inside a async function or have top-level await
await simply.https("postman-echo.com/get");
const simply = require("simply-https");
simply.https({
url: "postman-echo.com/get",
method: "GET",
headers: { "Content-Type": "application/json" },
});