Skip to content

Commit

Permalink
fix: make params an optional argument in requests
Browse files Browse the repository at this point in the history
This will allow to not invoke, e.g. `api.get('/foo', {})`, when one can
simply invoke `api.get('/foo')`.

Closes #7.
  • Loading branch information
tsufiev committed Feb 25, 2022
1 parent fdeec31 commit 1c3fa89
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default class AxiosWrapper {
}

async request<T = any>(methodParams: ApiMethodParams): Promise<T> {
const {method, url, data = null, params, options = {}, retries = 0} = methodParams;
const {method, url, data = null, params = {}, options = {}, retries = 0} = methodParams;

const axiosSettings: AxiosRequestConfig = options.requestConfig || {};
const {concurrentId, collectRequest = true, timeout, headers} = options;
Expand Down Expand Up @@ -207,8 +207,8 @@ export default class AxiosWrapper {

get<T = any>(
url: string,
params: ApiMethodParams['params'],
options: ApiMethodParams['options'] = {},
params?: ApiMethodParams['params'],
options?: ApiMethodParams['options'],
) {
return this.request<T>({
method: 'GET',
Expand All @@ -221,8 +221,8 @@ export default class AxiosWrapper {
post<T = any>(
url: string,
data: unknown,
params: ApiMethodParams['params'],
options: ApiMethodParams['options'] = {},
params?: ApiMethodParams['params'],
options?: ApiMethodParams['options'],
) {
return this.request<T>({
method: 'POST',
Expand All @@ -236,8 +236,8 @@ export default class AxiosWrapper {
put<T = any>(
url: string,
data: unknown,
params: ApiMethodParams['params'],
options: ApiMethodParams['options'] = {},
params?: ApiMethodParams['params'],
options?: ApiMethodParams['options'],
) {
return this.request<T>({
method: 'PUT',
Expand All @@ -251,8 +251,8 @@ export default class AxiosWrapper {
patch<T = any>(
url: string,
data: unknown,
params: ApiMethodParams['params'],
options: ApiMethodParams['options'] = {},
params?: ApiMethodParams['params'],
options?: ApiMethodParams['options'],
) {
return this.request<T>({
method: 'PATCH',
Expand All @@ -266,8 +266,8 @@ export default class AxiosWrapper {
delete<T = any>(
url: string,
data: unknown,
params: ApiMethodParams['params'],
options: ApiMethodParams['options'] = {},
params?: ApiMethodParams['params'],
options?: ApiMethodParams['options'],
) {
return this.request<T>({
method: 'DELETE',
Expand All @@ -280,8 +280,8 @@ export default class AxiosWrapper {

head<T = any>(
url: string,
params: ApiMethodParams['params'],
options: ApiMethodParams['options'] = {},
params?: ApiMethodParams['params'],
options?: ApiMethodParams['options'],
) {
return this.request<T>({
method: 'HEAD',
Expand Down

0 comments on commit 1c3fa89

Please sign in to comment.