Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NetworkError: 405 Method Not Allowed AngularJS REST

Tags:

angularjs

In AngularJS, I had the following function, which worked fine:

$http.get( "fruits.json" ).success( $scope.handleLoaded );

Now I would like to change this from a file to a url (that returns json using some sweet Laravel 4):

$http.get( "http://localhost/fruitapp/fruits").success( $scope.handleLoaded );

The error I get is:

"NetworkError: 405 Method Not Allowed - http://localhost/fruitapp/fruits"

What's the problem? Is it because fruit.json was "local" and localhost is not?

like image 726
Ben Avatar asked Apr 04 '13 00:04

Ben


1 Answers

From w3:

10.4.6 405 Method Not Allowed

The method specified in the Request-Line is not allowed for the resource 
identified by the Request-URI. The response MUST include an Allow header 
containing a list of valid methods for the requested resource.

It means the for the URL: http://localhost/fruitapp/fruits The server is responding that the GET method isn't allowed. Is it a POST or PUT?

like image 199
Xesued Avatar answered Oct 04 '22 04:10

Xesued