Skip to content

Commit c38bb71

Browse files
committed
Simplified singleton
1 parent de5cd8f commit c38bb71

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

dashboard/src/api/api.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
class Api {
2-
token = '';
1+
export default {
2+
token: '',
33

44
async decodeResults(result) {
55
const decoded = await result.json();
@@ -10,7 +10,7 @@ class Api {
1010
throw Error(`Unexpected status ${result.status}`);
1111
}
1212
return decoded;
13-
}
13+
},
1414

1515
// apiGet performs a GET request on the API with given local URL.
1616
// The result is decoded from JSON and returned.
@@ -23,7 +23,7 @@ class Api {
2323
}
2424
const result = await fetch(localURL, {headers});
2525
return this.decodeResults(result);
26-
}
26+
},
2727

2828
// apiPost performs a POST request on the API with given local URL and given data.
2929
// The result is decoded from JSON and returned.
@@ -42,8 +42,4 @@ class Api {
4242
});
4343
return this.decodeResults(result);
4444
}
45-
}
46-
47-
var api = new Api();
48-
49-
export default api;
45+
};

0 commit comments

Comments
 (0)