Skip to content

Commit 0f1478a

Browse files
committed
initial commit
0 parents  commit 0f1478a

9 files changed

+2876
-0
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

Diff for: README.md

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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+
- **Email**: [[email protected]](mailto:[email protected])
104+
- **GitHub**: [PB2204](https://github.com/pb2204)
105+
106+
Feel free to reach out for questions, feedback, or collaboration opportunities.

Diff for: STRUCTURE.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
```bash
2+
js-http/
3+
|-- dist/
4+
| |-- js-http.min.js
5+
|-- src/
6+
| |-- js-http.js
7+
|-- examples/
8+
| |-- index.html
9+
|-- tests/
10+
| |-- test-js-http.js
11+
|-- docs/
12+
| |-- index.html
13+
|-- README.md
14+
|-- package.json
15+
|-- webpack.config.js
16+
|-- .gitignore
17+
```

Diff for: docs/index.html

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!-- index.html -->
2+
3+
<!DOCTYPE html>
4+
<html lang="en">
5+
6+
<head>
7+
<meta charset="UTF-8">
8+
<title>JS-HTTP Library Test</title>
9+
</head>
10+
11+
<body>
12+
<h1>JS-HTTP Library Test</h1>
13+
<script src="dist/js-http.min.js"></script>
14+
<script>
15+
async function testJSHTTP() {
16+
try {
17+
const response = await JSHTTP.get('https://jsonplaceholder.typicode.com/posts/1');
18+
console.log('GET Response:', response);
19+
} catch (error) {
20+
console.error('GET Error:', error);
21+
}
22+
23+
try {
24+
const data = { userId: 1, id: 101, title: 'foo', body: 'bar' };
25+
const response = await JSHTTP.post('https://jsonplaceholder.typicode.com/posts', data);
26+
console.log('POST Response:', response);
27+
} catch (error) {
28+
console.error('POST Error:', error);
29+
}
30+
}
31+
32+
testJSHTTP();
33+
</script>
34+
</body>
35+
36+
</html>

0 commit comments

Comments
 (0)