【问题标题】:In Lumen Laravel 5.4 POST method not working在 Lumen Laravel 5.4 POST 方法不起作用
【发布时间】:2017-10-10 09:27:51
【问题描述】:

我使用 lumen laravel 作为后端。我正在尝试使用 angular2 从前端执行 POST 方法。 GET 方法工作正常。但是在尝试使用 POST 方法时,我收到错误为 405 Method Not Allowed Method not allowed 405 error

路由/web.php $app->post('/insert_data', 'ExampleController@testInsert');

【问题讨论】:

  • 发布您尝试调用 POST 方法的角度代码

标签: lumen


【解决方案1】:

问题在于我们需要发送的数据。您必须在发送 JSON 数据之前对其进行字符串化。例如:JSON.stringify(values)

this._http.post('http://local.amazonlaravel.com/api/add_products',JSON.stringify(values),{
})
.subscribe(
  res => {        
    // console.log(values);
  },
  err => {
    console.log("Error occured");
  }
);

【讨论】:

    猜你喜欢
    • 2018-03-30
    • 2015-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-01
    • 2018-04-21
    • 2017-12-13
    相关资源
    最近更新 更多