@@ -73,8 +73,6 @@ class BaseService {
73
73
return this . post < T > ( payload , config )
74
74
}
75
75
76
- put < T > ( payload : any ) : Promise < T >
77
- put < T > ( id : string | number , payload : any ) : Promise < T >
78
76
put < T > ( payload : any , config ?: AxiosRequestConfig ) : Promise < T >
79
77
put < T > (
80
78
id : string | number ,
@@ -83,15 +81,14 @@ class BaseService {
83
81
) : Promise < T >
84
82
put < T > ( id : string | number , payload ?: any , config ?: AxiosRequestConfig ) {
85
83
const parameter = id && ! isObject ( id ) ? `/${ id } ` : ''
86
- const requestType : Method = hasFiles ( payload ) ? 'post' : 'put'
87
- if ( hasFiles ( payload ) ) {
88
- Object . assign ( payload , { _method : 'put' } )
84
+ const body = isObject ( id ) ? id : payload
85
+ const requestType : Method = hasFiles ( body ) ? 'post' : 'put'
86
+ if ( hasFiles ( body ) ) {
87
+ Object . assign ( body , { _method : 'put' } )
89
88
}
90
- return this . submit < T > ( requestType , parameter , payload , config )
89
+ return this . submit < T > ( requestType , parameter , body , config )
91
90
}
92
91
93
- patch < T > ( payload : any ) : Promise < T >
94
- patch < T > ( id : string | number , payload : any ) : Promise < T >
95
92
patch < T > ( payload : any , config ?: AxiosRequestConfig ) : Promise < T >
96
93
patch < T > (
97
94
id : string | number ,
@@ -100,7 +97,8 @@ class BaseService {
100
97
) : Promise < T >
101
98
patch < T > ( id : string | number , payload ?: any , config ?: AxiosRequestConfig ) {
102
99
const parameter = id && ! isObject ( id ) ? `/${ id } ` : ''
103
- return this . submit < T > ( 'patch' , parameter , payload , config )
100
+ const body = isObject ( id ) ? id : payload
101
+ return this . submit < T > ( 'patch' , parameter , body , config )
104
102
}
105
103
106
104
update < T > ( id : string | number , payload : any ) {
@@ -115,19 +113,6 @@ class BaseService {
115
113
return this . delete < T > ( id )
116
114
}
117
115
118
- submit < T = any > ( requestType : Method ) : Promise < T >
119
- submit < T = any > ( requestType : Method , parameter ?: string | number ) : Promise < T >
120
- submit < T = any > (
121
- requestType : Method ,
122
- parameter ?: string | number ,
123
- form ?: T ,
124
- ) : Promise < T >
125
- submit < T = any > (
126
- requestType : Method ,
127
- parameter ?: string | number ,
128
- form ?: T ,
129
- config ?: AxiosRequestConfig ,
130
- ) : Promise < T >
131
116
submit < T = any > (
132
117
requestType : Method ,
133
118
parameter ?: string | number ,
0 commit comments