web/src/api/v1.ts

16 lines
284 B
TypeScript
Raw Normal View History

2021-12-29 19:44:08 +01:00
const API_PREFIX = '/api/v1'
2021-12-28 20:40:47 +01:00
export class RbApi {
2021-12-29 19:44:08 +01:00
async get_json (path) {
2021-12-28 20:40:47 +01:00
const url = `${API_PREFIX}${path}`
2021-12-29 19:44:08 +01:00
const res = await fetch(url)
2021-12-28 20:40:47 +01:00
return await res.json()
}
2021-12-29 19:44:08 +01:00
async sections () {
const res = await this.get_json('/sections')
2021-12-28 20:40:47 +01:00
2021-12-29 19:44:08 +01:00
return res.sections
2021-12-28 20:40:47 +01:00
}
}