Add apiService
This commit is contained in:
parent
65e556656f
commit
d9076e4367
|
@ -0,0 +1,17 @@
|
|||
export async function api(url) {
|
||||
const response = await fetch(url);
|
||||
if (response.ok) {
|
||||
const jsonValue = await response.json();
|
||||
return Promise.resolve(jsonValue);
|
||||
} else {
|
||||
return Promise.reject('Response was not OK.');
|
||||
}
|
||||
}
|
||||
|
||||
export async function getSession(sessionId) {
|
||||
return await api(`/api/sessions/${sessionId}/`);
|
||||
}
|
||||
|
||||
export async function getSessionList() {
|
||||
return await api(`/api/sessions/`);
|
||||
}
|
Loading…
Reference in New Issue