trigger screen

This commit is contained in:
IDONTSUDO 2023-11-01 18:24:43 +03:00
parent fbcfba3948
commit d10a829882
30 changed files with 19101 additions and 26 deletions

View 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()
}
}