Started writing API wrapper
This commit is contained in:
parent
9f61d8d48e
commit
66a7cd8def
5 changed files with 67 additions and 2 deletions
15
src/api/v1.ts
Normal file
15
src/api/v1.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
const API_PREFIX = "/api/v1"
|
||||
|
||||
export class RbApi {
|
||||
async get_json(path) {
|
||||
const url = `${API_PREFIX}${path}`
|
||||
let res = await fetch(url)
|
||||
return await res.json()
|
||||
}
|
||||
|
||||
async sections() {
|
||||
let res = await this.get_json("/sections")
|
||||
|
||||
return res["sections"]
|
||||
}
|
||||
}
|
||||
Reference in a new issue