Back

Lumen (API) Post 'Method Not Allowed'


I´m trying to create a simple API with Lumen and Ionic3. I have a post route to send form data to database and compare results, if array doesn't null, user can access.

In routes i have this piece of code


$app->post('/login', [
    'as' => 'login', 'uses' => '[email protected]'
]);

In ionic controller i have this

this.loginService.getLogin(this.login).then(data => {
    this.login = data.results;
})

And finally in service have this

getLogin(data) {
    return this.http.post('http://localhost:8000/login',data)
    .map(res => res.json())
    .toPromise();
}

In this step i have a GET http://localhost:8000/login 405 (Method Not Allowed) in console and all the proccess is stopped. I use this plugin to allow CORS, so isn´t a CORS error.

If getLogin() is ok it goes to lumen controller and execute query. The lumen controller is ok, i use Postman to check query.

¿Any idea?

UPDATE

Maybe i need to create login get method in routes ¿but it´s necessary? I only use post method to send data to database.


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us