Skip to content

Commit 9b324f5

Browse files
committed
fix: 🔥 fix put and path method with only payload
1 parent c3b501e commit 9b324f5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/core/BaseService.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ class BaseService {
8383
): Promise<T>
8484
put<T>(id: string | number, payload?: any, config?: AxiosRequestConfig) {
8585
const parameter = id && !isObject(id) ? `/${id}` : ''
86-
const requestType: Method = hasFiles(payload) ? 'post' : 'put'
87-
if (hasFiles(payload)) {
88-
Object.assign(payload, { _method: 'put' })
86+
const body = isObject(id) ? id : payload
87+
const requestType: Method = hasFiles(body) ? 'post' : 'put'
88+
if (hasFiles(body)) {
89+
Object.assign(body, { _method: 'put' })
8990
}
90-
return this.submit<T>(requestType, parameter, payload, config)
91+
return this.submit<T>(requestType, parameter, body, config)
9192
}
9293

9394
patch<T>(payload: any): Promise<T>
@@ -100,7 +101,8 @@ class BaseService {
100101
): Promise<T>
101102
patch<T>(id: string | number, payload?: any, config?: AxiosRequestConfig) {
102103
const parameter = id && !isObject(id) ? `/${id}` : ''
103-
return this.submit<T>('patch', parameter, payload, config)
104+
const body = isObject(id) ? id : payload
105+
return this.submit<T>('patch', parameter, body, config)
104106
}
105107

106108
update<T>(id: string | number, payload: any) {

0 commit comments

Comments
 (0)