【发布时间】:2018-07-28 00:24:39
【问题描述】:
我使用 Laravel 5.4 编写了一个 API,并使用 Vue.js 2 从我的前端连接到它。API 在http://localhost:8000/ 上运行,Vue 应用在http://localhost:8080/ 上运行。
我应该如何将它们部署在同一主机上?我应该怎么处理axios 这样的请求:
axios.post(`http://localhost:8000/api/requests`, {
'fname': this.fname,
'lname': this.lname,
'email': this.email,
'phone': this.phone
})
.then(response => {
if(response.data.success) {
this.showSpinner = false;
this.success = true;
this.message = response.data.message;
}
})
.catch(error => {
context.error = error;
});
解决方法是什么?
【问题讨论】:
标签: javascript laravel rest api vue.js