-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathexample.jsx
51 lines (37 loc) · 972 Bytes
/
example.jsx
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
#include "http.jsx"
// GET example
var data = $http({
method: 'GET',
url: 'http://date.jsontest.com/'
});
alert(data.payload.time);
// GET with query string example
data = $http({
method: 'GET',
url: 'http://md5.jsontest.com/?text=example_text'
});
alert(data.payload.md5);
// GET with custom headers
data = $http({
method: 'GET',
url: 'http://httpbin.org/headers',
headers: {'Hello': 'World'}
});
alert(data.payload.headers.Hello);
// POST example
var data = $http({
method: 'POST',
payload: '[email protected]',
url: 'http://httpbin.org/post',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
alert(data.payload.form.email);
// POST Json example (note, payload will be converted to json string and Content-Type: application/json will be automatically added to your request)
var data = $http({
method: 'POST',
payload: {email: '[email protected]'},
url: 'http://httpbin.org/post'
});
alert(data.payload.json.email);