#laravel #apache #vue.js
Вопрос:
после развертывания моего приложения laravel на сервере apache все работает правильно, за исключением компонента Vue в консоли, у меня возникла эта ошибка:
после развертывания моего приложения laravel на сервере apache все работает правильно, за исключением компонента Vue в консоли, у меня возникла эта ошибка:
[Vue warn]: Error in mounted hook (Promise / async): "Error: Network Error"
found in
---> <IndexComponent> at resources / js / components / IndexComponent.vue
<Root>
warn @ app.js: 39060
logError @ app.js: 40332
globalHandleError @ app.js: 40327
handleError @ app.js: 40287
(anonymous) @ app.js: 40304
Promise.catch (async)
invokeWithErrorHandling @ app.js: 40304
callHook @ app`enter code here`.js: 42669enter code here
insert @ app.js: 41595
invokeInsertHook @ app.js: 44822
patch @ app.js: 45041
Vue._update @ app.js: 42394
updateComponent @ app.js: 42515
get @ app.js: 42929
Watcher @ app.js: 42918
mountComponent @ app.js: 42522
Vue. $ Mount @ app.js: 47528
Vue. $ Mount @ app.js: 50442
Vue._init @ app.js: 43462
Vue @ app.js: 43529
./resources/js/app.js @ app.js: 2203
__webpack_require__ @ app.js: 50486
(anonymous) @ app.js: 50651
__webpack_require __. O @ app.js: 50523
(anonymous) @ app.js: 50653
(anonymous) @ app.js: 50655
app.js: 40336 Error: Network Error
at createError (app.js: 607)
at XMLHttpRequest.handleError (app.js: 104)
Код компонента индекса
<script>
export default {
props: { selected: Number, specializations: Array },
data() {
return {
specId: this.selected,
doctors: [],
results: true,
scTimer: 0,
scY: 0,
};
},
mounted() {
return this.filterSpec();
},
watch: {
specId: function () {
return this.filterSpec();
},
},
methods: {
sponsDoc: function (arr) {
// Set slice() to avoid to generate an infinite loop!
return arr.slice().sort(function (a, b) {
return b.att - a.att;
});
},
filterSpec: function () {
return await axios
.get("http://127.0.0.1:8000/api/doctors?specialization=" this.specId)
.then((resp) => {
this.doctors = resp.data;
// console.log(this.doctors);
this.doctors.forEach((doctor) => {
doctor.sponAtt = [];
var currentDate = new Date();
doctor.sponsors.forEach((spon) => {
spon.end = spon.pivot.expiration_time;
if (new Date(spon.end) > new Date(currentDate)) {
doctor.sponAtt.push(spon);
} else {
}
// console.log(spon.end);
});
doctor.att = doctor.sponAtt.length;
doctor.spec = [];
doctor.num = doctor.reviews.length;
var sum = doctor.reviews.reduce((acc, rew) => acc rew.vote, 0);
// console.log(sum);
var avarage = sum / doctor.num;
if (Number.isNaN(avarage)) {
doctor.avarage = 0;
} else {
doctor.avarage = avarage.toFixed(2);
}
doctor.specializations.forEach((spec) => {
doctor.spec.push(spec.name);
});
});
});
},
Комментарии:
1. Пожалуйста, не могли бы вы добавить код для вашего
IndexComponent
вопроса к вашему вопросу.2. локально работает отлично