@@ -11,6 +11,7 @@ export default class HttpClient {
1111 readonly GET = 'GET'
1212 readonly POST = 'POST'
1313 readonly POST_DATA = 'POST_DATA'
14+ readonly PATCH = 'PATCH'
1415 isDestroyed = false
1516
1617 constructor (
@@ -47,7 +48,7 @@ export default class HttpClient {
4748 }
4849
4950 fetch (
50- method : 'GET' | 'POST' | 'POST_DATA' ,
51+ method : 'GET' | 'POST' | 'POST_DATA' | 'PATCH' ,
5152 endpoint : string ,
5253 variables : any
5354 ) {
@@ -123,7 +124,7 @@ export default class HttpClient {
123124 }
124125
125126 fetchInternal (
126- method : 'GET' | 'POST' | 'POST_DATA' ,
127+ method : 'GET' | 'POST' | 'POST_DATA' | 'PATCH' ,
127128 endpoint : string ,
128129 variables : any
129130 ) {
@@ -135,6 +136,10 @@ export default class HttpClient {
135136 return this . postReq ( endpoint , variables , method )
136137 }
137138
139+ if ( method === this . PATCH ) {
140+ return this . patchReq ( endpoint , variables )
141+ }
142+
138143 throw new Error ( 'Unknown method: ' + method )
139144 }
140145
@@ -175,4 +180,16 @@ export default class HttpClient {
175180 return data
176181 } )
177182 }
183+
184+ patchReq ( endpoint : string , variables : any ) {
185+ const self = this
186+
187+ return Request . patch ( this . baseUrl + endpoint , {
188+ headers : self . createHeaders ( ) ,
189+ body : variables ,
190+ json : true
191+ } ) . then ( function ( data ) {
192+ return data
193+ } )
194+ }
178195}
0 commit comments