You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
761 B
TypeScript
34 lines
761 B
TypeScript
import fetch from 'axios';
|
|
|
|
import {HTTPMethod, RestCalls} from './restCalls';
|
|
|
|
class DefaultRestCalls implements RestCalls {
|
|
async fetchData(url: string, method: HTTPMethod, headers?: any): Promise<string> {
|
|
const ret = await fetch({
|
|
url,
|
|
method,
|
|
headers,
|
|
transformResponse: (req) => req,
|
|
withCredentials: true,
|
|
timeout: 29000,
|
|
});
|
|
return ret.data;
|
|
}
|
|
|
|
async sendData(url: string, method: HTTPMethod, data: string, headers?: any): Promise<string> {
|
|
const ret = await fetch({
|
|
url,
|
|
method,
|
|
data,
|
|
transformResponse: (req) => req,
|
|
headers,
|
|
withCredentials: true,
|
|
timeout: 29000,
|
|
});
|
|
return ret.data;
|
|
}
|
|
|
|
}
|
|
|
|
export const restCalls = new DefaultRestCalls();
|