My api.php inside Routes folder looks like this:
<?php
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::post('login', 'Api\User\LoginController@login');
and web.php is as follows:
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/system/login', 'System\LoginController@index');
This is code on index method of System\LoginController.php:
class LoginController extends Controller
{
use Requestable;
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$response = $this->post('api/login',$request->all());
$responseArray = json_decode($response->getBody(), true);
session()->put('access_token',$responseArray['data']['token']);
return redirect()->to('/system/dashboard');
//
}
So basically,I am consuming api within same project.The project folder is inside htdocs of xampp.So whenever I turn on and use Apache server,the api sends data just fine.However, if I use php artisan serve command to serve the project, every time I try to get data from api, Server doesn't throw any error but just hungs up and doesn't return data at all even after long time. I guess its the issue with how server behaves with artisan serve.Some body please help me get off of this issue?