-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.js
More file actions
28 lines (26 loc) · 798 Bytes
/
api.js
File metadata and controls
28 lines (26 loc) · 798 Bytes
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
module.exports = class ApiClient {
constructor() {
this.apiUrl = "https://aion-dev.herokuapp.com";
}
async getValue(projectKey, scope) {
const response = await fetch(`${this.apiUrl}/api/state/checkout/${projectKey}/${scope}`)
if (!response.ok) {
return null;
}
return await response.json();
}
async updateValue(key, value) {
const response = await fetch(`${this.apiUrl}/api/state/commit/${this._currentChangeId}/${this.scope}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(value)
});
const responseJson = await response.json();
if (responseJson['committed'] === undefined) {
throw "Change not committed, please check network!"
}
return resonseJson;
}
}