File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -68,12 +68,12 @@ class Client extends React.Component
6868 handleSubmit ( event ) {
6969
7070 let client = this . formatFormData ( ) ;
71- let method ;
71+ let id ;
7272 if ( typeof client . _id !== 'undefined' ) {
73- method = 'put' ;
73+ id = client . _id ;
7474 }
7575
76- ClientService . save ( client , method ) . then ( ( response ) => {
76+ ClientService . save ( client , id ) . then ( ( response ) => {
7777 this . context . router . push ( "/clients" ) ;
7878 } ) . catch ( ( error ) => {
7979
Original file line number Diff line number Diff line change @@ -26,9 +26,11 @@ const Client = {
2626 return axios . get ( url . join ( '/' ) , this . getConfig ( ) ) ;
2727 } ,
2828
29- save ( client , method = 'post' ) {
30- if ( method == 'put' ) {
31- return axios . put ( this . getEntryPoint ( ) . join ( '/' ) , client , this . getConfig ( ) ) ;
29+ save ( client , id = undefined ) {
30+ if ( id !== undefined ) {
31+ let url = this . getEntryPoint ( ) ;
32+ url . push ( id ) ;
33+ return axios . put ( url . join ( '/' ) , client , this . getConfig ( ) ) ;
3234 }
3335 return axios . post ( this . getEntryPoint ( ) . join ( '/' ) , client , this . getConfig ( ) ) ;
3436 }
You can’t perform that action at this time.
0 commit comments