@@ -26,21 +26,18 @@ export default {
2626 url : 'v1/profile' ,
2727 method : 'GET'
2828 } ) . then ( resp => {
29- console . log ( 'getProfilesFromApi' , resp )
3029 return resp . data . profiles
3130 } ) . catch ( err => {
3231 return err
3332 } )
3433 } ,
3534 async getSectorsFromApi ( institute = { id :'' } , direction = { id :'' } , profile = { id :'' } ) {
36- console . log ( 'getSectorsFromApi institute' , institute )
37- console . log ( 'getSectorsFromApi direction' , direction )
38- console . log ( 'getSectorsFromApi profile' , profile )
3935 return await axios . request ( {
4036 url : 'v1/sector' ,
4137 method : 'GET' ,
4238 params : { institute : institute . id , direction : direction . id , profile : profile . id }
4339 } ) . then ( resp => {
40+ console . log ( 'getSectorsFromApi ' , institute )
4441 return resp . data
4542 } ) . catch ( err => {
4643 return err
@@ -56,6 +53,30 @@ export default {
5653 alert ( 'Успешно создано!' )
5754 return resp . data
5855 } ) . catch ( err => {
56+ if ( err . response . status === 404 ) {
57+ console . log ( '404' , err . response . status , data . sectors . coords [ 0 ] )
58+ this . postNewSectorToApi ( data . sectors . coords [ 0 ] , data )
59+ }
60+ else {
61+ alert ( 'Не получилось, проверьте правильность ввденных данных' )
62+ }
63+ console . log ( err )
64+ return err
65+ } )
66+ } ,
67+ async postNewSectorToApi ( idSectors , dataLastRequest ) {
68+ return await axios . request ( {
69+ url : 'v1/sector' ,
70+ method : 'POST' ,
71+ data : {
72+ "coords" : idSectors
73+ }
74+ } ) . then ( resp => {
75+ console . log ( 'postNewSectorToApi ' , resp )
76+ this . postSectorsToApi ( dataLastRequest )
77+ return resp . data
78+ } ) . catch ( err => {
79+ console . log ( '404' , err . response . status , idSectors )
5980 alert ( 'Не получилось, проверьте правильность ввденных данных' )
6081 console . log ( err )
6182 return err
0 commit comments