-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenable-disable-cdn-js.php
90 lines (60 loc) · 1.81 KB
/
enable-disable-cdn-js.php
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<h3>Enable and Disable CDN</h3>
<!-- <input type="text" id="client_id" placeholder="Enter Client ID"></br>
<input type="text" id="client_secrect" placeholder="Enter Client Secret"></br>
<button onclick="submitform()">Save</button></br></br>
-->
<button onclick="enableCDN()">Enable CDN</button>
<button onclick="disableCDN()">Disable CDN</button>
</body>
</html>
<script type="text/javascript">
// const btn= document.getElementById("btn");
// btn.addEventListener('click', function(){
// var name = document.getElementById("client_id").value;
// alert("Name: "+ name);
// });
//Function to enable CDN
function enableCDN() {
fetch('https://my.pressable.com/v1/sites/ADD-SITE-ID-HERE/cdn', {
method: 'POST',
headers: {'Content-Type': 'application/json', "Authorization": 'Bearer ADD-ACCESSTOKEN-HERE',},
body: JSON.stringify({id: "200"})
}).then(response => {
if(response.ok){
return response.json();
}
throw new Error('Request failed!');
}, networkError => {
console.log(networkError.message);
}).then(jsonResponse => {
console.log(jsonResponse);
})
}
//Function to disable CDN
function disableCDN() {
fetch('https://my.pressable.com/v1/sites/ADD-SITE-ID-HERE/cdn', {
method: 'DELETE',
headers: {'Content-Type': 'application/json', "Authorization": 'Bearer ADD-ACCESSTOKEN-HERE',},
body: JSON.stringify({id: "200"})
}).then(response => {
if(response.ok){
return response.json();
}
throw new Error('Request failed!');
}, networkError => {
console.log(networkError.message);
}).then(jsonResponse => {
console.log(jsonResponse);
})
}
// function submitform()
// {
// if(document.myform.onsubmit &&
// !document.myform.onsubmit())
// {
// return;
// }
// document.myform.submit();
// }
</script>