vue-mobx-finegrained
Version:
Vue 3 composable for a complete MobX state management integration.
48 lines (42 loc) • 1.13 kB
text/typescript
import { inject, injectable } from 'inversify'
import { Config } from './Config'
import { UserModel } from '../Authentication/UserModel'
export class HttpGateway {
config
userModel
async get (path) {
const response = await fetch(this.config.apiUrl + path, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: this.userModel.token,
},
})
const dto = response.json()
return dto
}
async post (path, requestDto) {
const response = await fetch(this.config.apiUrl + path, {
method: 'POST',
body: JSON.stringify(requestDto),
headers: {
'Content-Type': 'application/json',
Authorization: this.userModel.token,
},
})
const dto = response.json()
return dto
}
async delete (path) {
const response = await fetch(this.config.apiUrl + path, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
Authorization: this.userModel.token,
},
})
const dto = response.json()
return dto
}
}