-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
50 lines (40 loc) · 1.3 KB
/
Copy pathindex.html
File metadata and controls
50 lines (40 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="./HttpRequests.class.js"></script>
</head>
<body>
<h1>HttpRequestsClass</h1>
<p>A class to easily send and process Http Requests.<br />
Check the console for more details.</p>
<script>
let httpRequests = new HttpRequests()
window.addEventListener('httpRequest', function (e) {
if( e.data.request_method === 'GET' ) {
console.log( e.data )
}
}, false);
httpRequests.get( 'https://jsonplaceholder.typicode.com/posts/1' ).then( json => console.log( json ) )
let post = {
title: 'foo',
body: 'bar',
userId: 1
}
httpRequests.post( post, 'https://jsonplaceholder.typicode.com/posts' ).then( json => console.log( json ) )
let post2 = {
id: 2,
title: 'foo',
body: 'bar',
userId: 1
}
httpRequests.put( post2, 'https://jsonplaceholder.typicode.com/posts/2' ).then( json => console.log( json ) )
let post3 = {
'title' : 'testtttt'
}
httpRequests.patch( post3, 'https://jsonplaceholder.typicode.com/posts/1' ).then( json => console.log( json ) )
httpRequests.delete( 'https://jsonplaceholder.typicode.com/posts/5' ).then( json => console.log( json ) )
</script>
</body>
</html>