9191<script >
9292import Sidebar from ' @/components/NavbarAndFooter/Sidebar.vue'
9393
94- import axios from ' axios '
94+ import { api } from ' @/plugins/api '
9595
9696export default {
9797 name: ' GuestsAdd' ,
@@ -126,7 +126,7 @@ export default {
126126 async created () {
127127 this .artikli = [];
128128 this .tags .forEach (async element => {
129- const resp = await axios .get (process . env . VUE_APP_BASE_URL + ' /cjenik/?ordering=order&search=' + element + ' &search_fields=tag' , )
129+ const resp = await api .get (' /cjenik/?ordering=order&search=' + element + ' &search_fields=tag' )
130130 if (resp .data .length != 0 ) {
131131 resp .data .forEach (element => {
132132 this .artikli .push (element)
@@ -142,13 +142,8 @@ export default {
142142
143143 if (curIndex != " 0" ) {
144144 if (artikl .tag == nextArtikl .tag ) {
145- await axios .put (process .env .VUE_APP_BASE_URL + ' /cjenik/' + artikl .id + ' /' ,
146- { order: nextArtikl .order },
147- { auth: { username: process .env .VUE_APP_DJANGO_USER , password: process .env .VUE_APP_DJANGO_PASS } })
148-
149- await axios .put (process .env .VUE_APP_BASE_URL + ' /cjenik/' + nextArtikl .id + ' /' ,
150- { order: artikl .order },
151- { auth: { username: process .env .VUE_APP_DJANGO_USER , password: process .env .VUE_APP_DJANGO_PASS } })
145+ await api .put (' /cjenik/' + artikl .id + ' /' , { order: nextArtikl .order })
146+ await api .put (' /cjenik/' + nextArtikl .id + ' /' , { order: artikl .order })
152147 }
153148 window .location .reload ();
154149 }
@@ -160,13 +155,8 @@ export default {
160155
161156 if (nextIndex != this .artikli .length ) {
162157 if (artikl .tag == nextArtikl .tag ) {
163- await axios .put (process .env .VUE_APP_BASE_URL + ' /cjenik/' + artikl .id + ' /' ,
164- { order: nextArtikl .order },
165- { auth: { username: process .env .VUE_APP_DJANGO_USER , password: process .env .VUE_APP_DJANGO_PASS } })
166-
167- await axios .put (process .env .VUE_APP_BASE_URL + ' /cjenik/' + nextArtikl .id + ' /' ,
168- { order: artikl .order },
169- { auth: { username: process .env .VUE_APP_DJANGO_USER , password: process .env .VUE_APP_DJANGO_PASS } })
158+ await api .put (' /cjenik/' + artikl .id + ' /' , { order: nextArtikl .order })
159+ await api .put (' /cjenik/' + nextArtikl .id + ' /' , { order: artikl .order })
170160 }
171161 this .created ()
172162 }
@@ -187,7 +177,7 @@ export default {
187177 },
188178
189179 async postArtikl () {
190- const resp = await axios .get (process . env . VUE_APP_BASE_URL + ' /cjenik/?ordering=order&search=' + this .selectedTag + ' &search_fields=tag' , )
180+ const resp = await api .get (' /cjenik/?ordering=order&search=' + this .selectedTag + ' &search_fields=tag' )
191181 let nextOrder = " 00" ;
192182
193183 let cjenik = resp .data ;
@@ -207,18 +197,15 @@ export default {
207197 }
208198 }
209199
210- axios .post (process .env .VUE_APP_BASE_URL + ' /cjenik/' ,
211- { name: this .name , tag: this .selectedTag , order: nextOrder, priceEUR: this .priceEUR , volume: this .volume },
212- { auth: { username: process .env .VUE_APP_DJANGO_USER , password: process .env .VUE_APP_DJANGO_PASS } }
200+ api .post (' /cjenik/' ,
201+ { name: this .name , tag: this .selectedTag , order: nextOrder, priceEUR: this .priceEUR , volume: this .volume }
213202 ).then (() => {
214203 this .created ()
215204 })
216205
217206 },
218207 deleteArtikl (artikl ) {
219- axios .delete (process .env .VUE_APP_BASE_URL + ' /cjenik/' + artikl .id + ' /' ,
220- { auth: { username: process .env .VUE_APP_DJANGO_USER , password: process .env .VUE_APP_DJANGO_PASS } }
221- )
208+ api .delete (' /cjenik/' + artikl .id + ' /' )
222209 .then (() => {
223210 this .created ()
224211 })
0 commit comments