c1186e4074
* login * login state management * API baseline code * load tracks * show tracks * basic routing * basic styling * add react-semantic-ui * add typescript
22 lines
402 B
JavaScript
22 lines
402 B
JavaScript
class API {
|
|
setAuthorizationHeader(authorization) {
|
|
this.authorization = authorization
|
|
}
|
|
|
|
async fetch(url, options = {}) {
|
|
const response = await window.fetch('/api' + url, {
|
|
...options,
|
|
headers: {
|
|
...(options.headers || {}),
|
|
Authorization: this.authorization,
|
|
},
|
|
})
|
|
|
|
return await response.json()
|
|
}
|
|
}
|
|
|
|
const api = new API()
|
|
|
|
export default api
|