trigger screen
This commit is contained in:
parent
fbcfba3948
commit
d10a829882
30 changed files with 19101 additions and 26 deletions
32
ui/src/core/repository/http_repository.ts
Normal file
32
ui/src/core/repository/http_repository.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
export enum HttpMethod {
|
||||
GET = 'GET',
|
||||
POST = 'POST'
|
||||
}
|
||||
|
||||
export class HttpRepository {
|
||||
|
||||
private server = 'http://localhost:3000'
|
||||
|
||||
public async jsonRequest<T>(method: HttpMethod, url: string, data?: any): Promise<T> {
|
||||
const reqInit = {
|
||||
'body': data,
|
||||
'method': method,
|
||||
'headers': { 'Content-Type': 'application/json' },
|
||||
}
|
||||
if (data !== undefined) {
|
||||
reqInit['body'] = JSON.stringify(data)
|
||||
}
|
||||
return (await fetch(this.server + url, reqInit)).json()
|
||||
}
|
||||
|
||||
public async request<T>(method: HttpMethod, url: string, data?: any): Promise<T> {
|
||||
const reqInit = {
|
||||
'body': data,
|
||||
'method': method,
|
||||
}
|
||||
if (data !== undefined) {
|
||||
reqInit['body'] = data
|
||||
}
|
||||
return (await fetch(this.server + url, reqInit)).json()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue