Add apiService
This commit is contained in:
parent
d4c0d47712
commit
5756b736d8
|
@ -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