Search code examples
phpreactjsaxioslumenlumen-5.4

MethodNotAllowedHttpException (lumen) while making request with 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);
});

enter image description here

thanks in advance...


Solution

  • Your application is not accepting the Cross domain requests I guess.

    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.

    See if this can help.

    I cannot comment so writing this solution here.