繁体   English   中英

Angular http GET 405(不允许使用方法)

[英]Angular http GET 405 (Method Not Allowed)

我在应用程序中实现了另一个功能(使用角度创建),调用了API(使用Lumen创建),它返回了405错误,我在本地尝试过,并且“ XMLHttpRequest无法加载预检响应无效(重定向)”我在服务器上尝试过。 我读到有关CORS的信息,但它已经实现了,我认为如果不是这样的话,其他功能将无法正常工作。

另一件事,如果我通过Advanced Rest Client拨打电话,则效果很好:(

对不起我的英语,我不太会说。

应用功能

$scope.agencias = [];

$http({
    method: 'GET',
    //url: 'http://api-beta.grupoaldorf.com.mx/agencias/',
    url: 'http://localhost:8000/agencias/',
    headers: agenciaMazda.headers
}).then(function successCallback(response) {
    $scope.agencias = response.data;
    console.log("regreso del http");
    console.log($scope.agencias);
}, function errorCallback(response) {
    //callback(false);
});

在web.php上路由

$app->get('agencias','CitasController@agenciasDisponibles');

CitasController.php中的控制器

public function agenciasDisponibles(Agencia $agencia){
    $fabricante = $this->request->header('Aldorf-App');
    $disponibles = Agencia::where('fabricante', $fabricante)->where('mostrar', 1)->select(['codigo', 'nombre'])->get();
    return $disponibles;
}

终于我解决了,它真的很笨,我在uri xD的末尾添加了一个斜杠,它必须是“ http:// localhost:8000 / agencias ”而不是“ http:// localhost:8000 / agencias /

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM