MethodNotAllowedHttpException (lumen) while making request with axios(使用 axios 发出请求时的 MethodNotAllowedHttpException (lumen))
问题描述
创建了一个在 lumen 中插入 todo 的路由,它使用 postman 可以完美地工作,但是在我用 axios 发送的反应应用程序请求中,它收到错误
Created a route for inserting todo in lumen , its working perfectly using postman but in my react application request sending with axios , it getting error
this.apiUrl = 'http://lumenback.dev/createTodo';
axios.post(this.apiUrl, {
todo: this.state.todo,
todo_date: this.props.curDate
})
.then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
提前致谢...
推荐答案
我猜你的应用程序不接受跨域请求.
Your application is not accepting the Cross domain requests I guess.
这是一个答案 Lumen API CORS Ajax 405不允许的方法我写信来设置 Cors 并使其与 React 和 Lumen 5.5 一起使用.
Here is an answer Lumen API CORS Ajax 405 Method Not Allowed I wrote to setup Cors and make it working with React and Lumen 5.5.
看看这是否有帮助.
我无法评论所以在这里写这个解决方案.
I cannot comment so writing this solution here.
这篇关于使用 axios 发出请求时的 MethodNotAllowedHttpException (lumen)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 axios 发出请求时的 MethodNotAllowedHttpException (lumen)
基础教程推荐
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01