lundi 4 juin 2018

Laravel AngularJS $http request alway empty

I know there's already a lot of answers to this question but none of them seems to match to my problem so here it is.

I'm using AngularJS's $http to make a GET request to my Laravel 5.6 controller.

The controller ClientsController looks like :

<?php

namespace App\Http\Controllers\Admin;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use Illuminate\Http\Request;

use App\Client;

class ClientsController extends Controller
{
    public function activate($id) {
        $client = Client::find($id);
        return $client;
    }

}

where App\Client refers to an existing model.

On route, it looks like :

Route::get('/clients/activate/{id}', 'Admin\\ClientsController@activate');

and the request form angularJS :

$http({
    url: client_url_with_id
    method: "GET"
}).then(function(response) {
    console.log(response.data);
});

It always shows empty. I don't understand why.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire