I have a route defined in routes.php file but when i make an ajax request from my angular app, i get this error
JavaScript
x
{"error":{"type":"Symfony\Component\HttpKernel\Exception\NotFoundHttpException","message":"Controller method not found.","file":"C:\xampp\htdocs\tedxph\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Controller.php","line":290}}
this is my routes file
JavaScript
/*
|--------------------------------------------------------------------------
| Api Routes
|--------------------------------------------------------------------------
*/
Route::group(array('prefix' => 'api'), function() {
//Auth Routes
Route::post('auth/login', 'ApiUserController@authUser');
Route::post('auth/signup', 'ApiUserController@registerUser');
/* Persons */
Route::group(array('prefix' => 'people'), function() {
Route::get('{id}', 'ApiPeopleController@read');
Route::get('/', 'ApiPeopleController@read');
});
/* Events */
Route::group(array('prefix' => 'events'), function() {
Route::get('{id}', 'ApiEventsController@read');
Route::get('/','ApiEventsController@read');
});
});
Accessing the same url
(http://localhost/site/public/api/auth/signup)
from a rest client app on chrome does not give any errors, what could be wrong?
this is the angular code from my controller
JavaScript
$rootScope.show('Please wait..registering');
API.register({email: email, password: password})
.success(function (data) {
if(data.status == "success") {
console.log(data);
$rootScope.hide();
}
})
.error(function (error) {
console.log(error)
$rootScope.hide();
})
more angular code
JavaScript
angular.module('tedxph.API', [])
.factory('API', function ($rootScope, $http, $ionicLoading, $window) {
//base url
var base = "http://localhost/tedxph/public/api";
return {
auth: function (form) {
return $http.post(base+"/auth/login", form);
},
register: function (form) {
return $http.post(base+"/auth/signup", form);
},
fetchPeople: function () {
return $http.get(base+"/people");
},
fetchEvents: function() {
return $http.get(base+"/events");
},
}
});
Advertisement
Answer
Fixed the problem, turns my controller was calling an undefined method in the controller class. Renamed the method correctly and the request now works, thanks guys for the input.