-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-client-behavior.html
More file actions
73 lines (59 loc) · 1.54 KB
/
api-client-behavior.html
File metadata and controls
73 lines (59 loc) · 1.54 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<script>
window.PolymerApigility = window.PolymerApigility || {};
PolymerApigility.ApiClientBehavior = {
properties: {
baseUrl: {
type: String,
value: null
},
method: {
type: String,
value: 'GET'
},
contentType: {
type: String,
value: null
},
headers: {
type: Object,
value: null
},
query: {
type: Object,
value: null
},
body: {
type: Object,
value: null
},
loading: {
type: Boolean,
notify: true
}
},
ready: function () {
if (this.$.ironAjax) {
this.$.ironAjax.addEventListener('response', this.responseApiClientListener.bind(this));
this.$.ironAjax.addEventListener('error', this.responseErrorHandler.bind(this));
} else {
throw "Iron ajax not found";
}
},
/**
* Success response handler
*
* @param e
*/
responseApiClientListener: function (e) {
e.detail.apiClient = this;
},
/**
* Error response handler
*
* @param e
*/
responseErrorHandler: function (e) {
e.detail.apiClient = this;
}
};
</script>