File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -330,6 +330,13 @@ describe('BaseProxy', () => {
330330 expect ( data ) . toEqual ( item )
331331 } )
332332
333+ it ( 'it should be able to put item without id parameter' , async ( ) => {
334+ const item = { first_name : 'Chantouch' , last_name : 'Sek' , id : 1 }
335+ mockAdapter . onPut ( 'posts' ) . reply ( 200 , { data : item } )
336+ const { data } = await proxy . putWithoutId ( item )
337+ expect ( data ) . toEqual ( item )
338+ } )
339+
333340 it ( 'it should be able to patch item' , async ( ) => {
334341 const item = { first_name : 'Chantouch' , last_name : 'Sek' , id : 1 }
335342 mockAdapter . onPatch ( 'posts/1' ) . reply ( 200 , { data : item } )
Original file line number Diff line number Diff line change @@ -121,6 +121,14 @@ class BaseProxy {
121121 return this . submit < T > ( 'put' , `/${ id } ` , payload )
122122 }
123123
124+ /**
125+ * Update record without ID parameter by using PUT method
126+ * @param {Object|string } payload
127+ */
128+ putWithoutId < T > ( payload : any ) {
129+ return this . submit < T > ( 'put' , '' , payload )
130+ }
131+
124132 /**
125133 * Alternative of put method
126134 * @param {string|number } id
You can’t perform that action at this time.
0 commit comments