|
| 1 | +# JS-HTTP |
| 2 | + |
| 3 | +A simple JavaScript HTTP request library for making GET and POST requests using the Fetch API. |
| 4 | + |
| 5 | +- [Installation](#installation) |
| 6 | +- [Project Structure](#project-structure) |
| 7 | +- [Overview](#overview) |
| 8 | +- [Examples](#examples) |
| 9 | +- [Usage](#usage) |
| 10 | +- [License](#license) |
| 11 | +- [Code of Conduct](CODE_OF_CONDUCT.md) |
| 12 | +- [Contributing](CONTRIBUTING.md) |
| 13 | +- [Learn More](LEARN.md) |
| 14 | +- [Developer Details](#developer-details) |
| 15 | + |
| 16 | +## Installation |
| 17 | + |
| 18 | +You can install JS-HTTP using npm: |
| 19 | + |
| 20 | +```bash |
| 21 | +npm i https-node.js |
| 22 | +``` |
| 23 | + |
| 24 | +## Project Structure |
| 25 | + |
| 26 | +The project structure is organized as follows: |
| 27 | + |
| 28 | +```bash |
| 29 | +js-http/ |
| 30 | +|-- dist/ |
| 31 | +|-- src/ |
| 32 | +| |-- js-http.js |
| 33 | +|-- examples/ |
| 34 | +| |-- index.html |
| 35 | +|-- tests/ |
| 36 | +| |-- test-js-http.js |
| 37 | +|-- CODE_OF_CONDUCT.md |
| 38 | +|-- CONTRIBUTING.md |
| 39 | +|-- LEARN.md |
| 40 | +|-- README.md |
| 41 | +|-- LICENSE |
| 42 | +|-- package.json |
| 43 | +|-- webpack.config.js |
| 44 | +|-- .gitignore |
| 45 | +``` |
| 46 | + |
| 47 | +- **`dist/`**: Contains the distribution version of the library. |
| 48 | +- **`src/`**: Contains the source code of the library. |
| 49 | +- **`examples/`**: Includes HTML examples demonstrating library usage. |
| 50 | +- **`tests/`**: Contains test files for the library. |
| 51 | +- **`CODE_OF_CONDUCT.md`**: Guidelines for community behavior. |
| 52 | +- **`CONTRIBUTING.md`**: Information on how to contribute to the project. |
| 53 | +- **`LEARN.md`**: Additional resources and learning materials. |
| 54 | +- **`README.md`**: This README file. |
| 55 | +- **`LICENSE`**: The license file for the project. |
| 56 | +- **`package.json`**: Configuration file for npm. |
| 57 | +- **`webpack.config.js`**: Configuration for bundling the library. |
| 58 | +- **`.gitignore`**: Specifies files and directories to be ignored by Git. |
| 59 | + |
| 60 | +## Overview |
| 61 | + |
| 62 | +JS-HTTP is a lightweight JavaScript library that simplifies making HTTP requests in your web applications. It provides a straightforward API for making GET and POST requests using the Fetch API. |
| 63 | + |
| 64 | +## Examples |
| 65 | + |
| 66 | +You can find usage examples in the `examples/` directory. To run the examples, open the HTML files in your browser. |
| 67 | + |
| 68 | +## Usage |
| 69 | + |
| 70 | +Here's how you can use JS-HTTP in your JavaScript code: |
| 71 | + |
| 72 | +```javascript |
| 73 | +// Import the JS-HTTP library |
| 74 | +const JSHTTP = require('https-node.js); |
| 75 | +
|
| 76 | +// Make a GET request |
| 77 | +JSHTTP.get('https://jsonplaceholder.typicode.com/posts/1') |
| 78 | + .then(response => { |
| 79 | + console.log('GET Response:', response); |
| 80 | + }) |
| 81 | + .catch(error => { |
| 82 | + console.error('GET Error:', error); |
| 83 | + }); |
| 84 | + |
| 85 | +// Make a POST request |
| 86 | +const data = { userId: 1, id: 101, title: 'foo', body: 'bar' }; |
| 87 | +JSHTTP.post('https://jsonplaceholder.typicode.com/posts', data) |
| 88 | + .then(response => { |
| 89 | + console.log('POST Response:', response); |
| 90 | + }) |
| 91 | + .catch(error => { |
| 92 | + console.error('POST Error:', error); |
| 93 | + }); |
| 94 | +``` |
| 95 | +
|
| 96 | +## License |
| 97 | +
|
| 98 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 99 | +
|
| 100 | +## Developer Details |
| 101 | +
|
| 102 | +- **Author**: [Pabitra Banerjee](https://pabitrabanerjee.me) |
| 103 | + |
| 104 | +- **GitHub**: [PB2204](https://github.com/pb2204) |
| 105 | +
|
| 106 | +Feel free to reach out for questions, feedback, or collaboration opportunities. |
0 commit comments