-
Notifications
You must be signed in to change notification settings - Fork 3
/
garden.js
34 lines (31 loc) · 924 Bytes
/
garden.js
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
/** Support library for gardening UI
*
* Warning: This does not work yet. We get CORS errors.
*/
GITHUB_API_URL_BASE = 'https://api.github.com/repos/';
var addLabel = function(issue_url, label) {
var url = issue_url + '/labels';
console.log('post: ' + url);
fetch(url, {
method: 'POST',
credentials: 'include',
body: JSON.stringify({'labels': [label]}),
headers: {
'Content-Type': 'application/json'
}
}).then((response) => {
return response.json();
}).then((response) => {
console.log(JSON.stringify(response));
}
).catch((error) => {
console.log('label update failed, you may have to authenticate at github.com:' + error.message);
});
};
var removeLabel = function(issue_url, label) {
console.log('Remove label: ' + label);
};
replaceLabel = function(issue_url, oldLabel, newLabel) {
addLabel(issue_url, newLabel);
removeLabel(issue_url, oldLabel);
};