DEV Community

Susheel kumar
Susheel kumar

Posted on

file_get_contents() equivalent for Node.JS

saksh-fetch-url: Effortless URL Content Retrieval

saksh-fetch-url is a simple Node.js package designed to fetch the contents of any given URL, be it a local file or a remote web resource.

Features:

  • Easy to Use: Simple API with a single function, file_get_contents.
  • Asynchronous: Leverages async/await for efficient, non-blocking operations.
  • Error Handling: Includes try/catch blocks to gracefully handle potential errors.
  • Flexible: Works seamlessly with both local files and remote URLs.

Installation:

npm install saksh-fetch-url
Enter fullscreen mode Exit fullscreen mode

Usage:

const file_get_contents = require('saksh-fetch-url');


const data = await file_get_contents('https://example.com');
console.log(data);


const dataLocal = await file_get_contents('./example.txt');
console.log(dataLocal );


Enter fullscreen mode Exit fullscreen mode

License:

This project is licensed under the MIT License.

Contributing:

We welcome contributions! Please open an issue or submit a pull request.

Contact:

For any questions or feedback, please contact susheel2339@gmail.com.

Top comments (0)