This project is a Work in Progress and currently in development. The API is subject to change without warning.
A small fetching package for super simple usages.
Built using zero dependencies to be lightweight and asynchronous
Lightfetch gives you the best of size, speed, and usability.
Install
npm install lightfetch-node
Usage
Main API
await lightfetch(url, [options]);
Options
- method: HTTP Request Method
- headers: HTTP Headers to use in Request
- body: Data to use in the Request*
* Data that can be used in body includes an Object, a string that's in x-www-form-urlencoded format, or plain text. Lightfetch will figure out what you pass in automagically and set the appropriate headers.
Example
// using CommonJS
const { lightfetch } = require('lightfetch-node');
// using ESM
import { lightfetch } from 'lightfetch-node';
async function fetch(url) {
const res = await lightfetch(url, {
method: 'GET',
headers: {
'X-Requested-With': 'RayhanADev',
},
});
console.log('Status:', res.status);
console.log('Response:', res.toJSON());
}
fetch('https://postman-echo.com/get?foo=bar');