-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-client-config-behavior.html
More file actions
42 lines (34 loc) · 1.29 KB
/
api-client-config-behavior.html
File metadata and controls
42 lines (34 loc) · 1.29 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
<script>
window.PolymerApigility = window.PolymerApigility || {};
PolymerApigility.ApiClientConfigBehavior = {
ready: function () {
if (!this.$.ironAjax) {
throw "Iron ajax not found";
}
/**
* Set baseUrl if isn't set on the custom element attributes
*/
var baseUrl = new Polymer.IronMetaQuery({type:'apigility', key: 'base-url'}).value;
if (!this.baseUrl && baseUrl) {
this.baseUrl = baseUrl;
}
/**
* Set contentType if isn't set on the custom element attributes
*/
var contentType = new Polymer.IronMetaQuery({type:'apigility', key: 'content-type'}).value;
if (!this.contentType && contentType) {
this.$.ironAjax.contentType = contentType;
}
var headers = new Polymer.IronMetaQuery({type:'apigility', key: 'headers'}).value;
switch (typeof headers) {
case 'string':
try { headers = JSON.parse(headers); }
catch(e) { headers = null; }
break;
}
if (headers) {
this.$.ironAjax.headers = headers;
}
}
};
</script>