currently everything working

This commit is contained in:
vabene1111
2021-01-12 19:50:21 +01:00
parent 7b936ec4fd
commit 816ced83b5
6 changed files with 31 additions and 17 deletions

View File

@ -18,13 +18,10 @@ import {BootstrapVue} from 'bootstrap-vue'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import {makeToast} from "@/utils/utils.js";
//import {gettext} from "@/utils/jsi18n";
const _ = window.gettext
import Step from "@/components/Step";
import axios from "axios";
Vue.use(BootstrapVue)
@ -38,6 +35,7 @@ const store = new Vuex.Store({
}
})
import {apiLoadRecipe} from "@/utils/django";
export default {
name: 'RecipeView',
@ -48,29 +46,24 @@ export default {
data() {
return {
loading: true,
recipe_id: window.RECIPE_ID,
recipe: undefined,
servings: 1,
}
},
mounted() {
//makeToast("Error", "Error", "danger")
this.loadRecipe(5)
console.log(_('Error'))
this.loadRecipe(this.recipe_id)
},
methods: {
loadRecipe: function (recipe_id) {
axios.get(`/api/recipe/${recipe_id}`).then((response) => {
this.recipe = response.data;
this.loading = false;
}).catch((err) => {
console.log(err)
makeToast('Error', 'There was an error loading a resource!', 'danger')
apiLoadRecipe(recipe_id).then(recipe => {
this.recipe = recipe
this.loading = false
})
}
}
}
</script>
<style>

View File

@ -4,5 +4,5 @@ import App from './RecipeView.vue'
Vue.config.productionTip = false
new Vue({
render: h => h(App),
render: h => h(App),
}).$mount('#app')

12
vue/src/utils/django.js Normal file
View File

@ -0,0 +1,12 @@
import axios from "axios";
import {makeToast} from "@/utils/utils";
export function apiLoadRecipe(recipe_id) {
return axios.get(`/api/recipe/${recipe_id}`).then((response) => {
return response.data
}).catch((err) => {
console.log(err)
makeToast('Error', 'There was an error loading a resource!', 'danger')
})
}