(refactor) move http service to core package
This commit is contained in:
parent
bef8f1d9e9
commit
e198e0fdcf
@ -6,4 +6,5 @@ export * from './localization/index'
|
||||
export * from './util/index'
|
||||
export * from './animation/index'
|
||||
export * from './factory/index'
|
||||
export * from './viewmodel/index'
|
||||
export * from './viewmodel/index'
|
||||
export * from './service/index'
|
||||
3
core/src/service/httpService.ts
Normal file
3
core/src/service/httpService.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export interface HttpService {
|
||||
get: (route: string) => Promise<Response>;
|
||||
}
|
||||
1
core/src/service/index.ts
Normal file
1
core/src/service/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './httpService'
|
||||
@ -1,8 +1,4 @@
|
||||
import { server } from "../const/config";
|
||||
|
||||
export interface HttpService {
|
||||
get: (route: string) => Promise<Response>;
|
||||
}
|
||||
import { HttpService } from "@mancala/core"
|
||||
|
||||
export class HttpServiceImpl implements HttpService {
|
||||
public serverAdress: string;
|
||||
@ -12,7 +8,7 @@ export class HttpServiceImpl implements HttpService {
|
||||
}
|
||||
|
||||
public async get(route: string): Promise<Response> {
|
||||
const url = server.serverAdress + route;
|
||||
const url = this.serverAdress + route;
|
||||
const requestOptions = {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@ -20,4 +16,4 @@ export class HttpServiceImpl implements HttpService {
|
||||
const response = await fetch(url, requestOptions);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,4 @@
|
||||
import { server } from "../const/config";
|
||||
|
||||
export interface HttpService {
|
||||
get: (route: string) => Promise<Response>;
|
||||
}
|
||||
import { HttpService } from "@mancala/core"
|
||||
|
||||
export class HttpServiceImpl implements HttpService {
|
||||
public serverAdress: string;
|
||||
@ -12,7 +8,7 @@ export class HttpServiceImpl implements HttpService {
|
||||
}
|
||||
|
||||
public async get(route: string): Promise<Response> {
|
||||
const url = server.serverAdress + route;
|
||||
const url = this.serverAdress + route;
|
||||
const requestOptions = {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@ -20,4 +16,4 @@ export class HttpServiceImpl implements HttpService {
|
||||
const response = await fetch(url, requestOptions);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user