Laravel 5.4 inconsistent no response and no error in logs2019 Community Moderator ElectionHow do I get PHP errors to display?How do I set up middleware in laravelAuth::user() returns nullHow do I use the / (index) route twice for both logged in and logged out?Laravel 5.2 - access authenticated user in route bindingLaravel 5.4 redirect to specific page if user is not authenticated using middlewareLaravel 5.4 Auth API routeLaravel 5.6 - How to get auth()->user() or $response->user() in api controller?Laravel: how to get current user in public routeLaravel 5.6.28: Auth Middleware redirects to Login (handle not called)

Too soon for a plot twist?

Professor forcing me to attend a conference, I can't afford even with 50% funding

After Brexit, will the EU recognize British passports that are valid for more than ten years?

Why does a car's steering wheel get lighter with increasing speed

Is it appropriate to ask a former professor to order a library book for me through ILL?

Short story about cities being connected by a conveyor belt

What does it take to become a wilderness skills guide as a business?

Interpretation of linear regression interaction term plot

Sort array by month and year

Where is the License file location for Identity Server in Sitecore 9.1?

Limpar string com Regex

Is this Paypal Github SDK reference really a dangerous site?

How can I have x-axis ticks that show ticks scaled in powers of ten?

Are small insurances worth it?

Should I file my taxes? No income, unemployed, but paid 2k in student loan interest

Cycles on the torus

Will the concrete slab in a partially heated shed conduct a lot of heat to the unconditioned area?

Should I apply for my boss's promotion?

Inorganic chemistry handbook with reaction lists

Why do we call complex numbers “numbers” but we don’t consider 2-vectors numbers?

Can I negotiate a patent idea for a raise, under French law?

Was it really inappropriate to write a pull request for the company I interviewed with?

Issue with units for a rocket nozzle throat area problem

Generating a list with duplicate entries



Laravel 5.4 inconsistent no response and no error in logs



2019 Community Moderator ElectionHow do I get PHP errors to display?How do I set up middleware in laravelAuth::user() returns nullHow do I use the / (index) route twice for both logged in and logged out?Laravel 5.2 - access authenticated user in route bindingLaravel 5.4 redirect to specific page if user is not authenticated using middlewareLaravel 5.4 Auth API routeLaravel 5.6 - How to get auth()->user() or $response->user() in api controller?Laravel: how to get current user in public routeLaravel 5.6.28: Auth Middleware redirects to Login (handle not called)










0















IMPORTANT EDIT: I cannot seem to be able to replicate the issue on Chrome, it is intermittent on Firefox (about 50/50). And is happening even more on Edge (about 70/30).



I have checked other similar questions but they do not resolve the issue.



I am using Angular JS with Laravel 5.4, sending a GET request and it is sometimes succeeding and sometimes failing. When I say failing I mean I am literally getting nothing back. I am getting no error and I can confirm laravel.log file is logging other errors but nothing for this.



In my console I have two examples that were done one after the other.



The request is called get-user-roles and the function is called at UserController@getUserRoles



Failed:
enter image description here



Succeeded:
enter image description here
You can see in the second one I am getting blank data back as expected.



Here is my web.php in /routes



Route::group(
[
'middleware' => ['cors', 'switchdb'],

], function ()

// auth

Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]);
Route::post('authenticate', 'AuthenticateController@authenticate');

Route::group(
[
'middleware' => ['jwt.auth'],

], function ()
Route::get('get-user-roles', 'UserController@getUserRoles');
);

Route::group(
[
'middleware' => ['jwt.auth', 'is-not-customer'],

], function ()
// more functions
);
);


Here is my controller UserController



<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppUser;
use AppRole;
use AppHttpRequestsPublishUserRequest;
use AppHttpRequestsChangePasswordRequest;
use Auth;


class UserController extends Controller


protected $user;

public function __construct()

$this->user = new User();


public function getUserRoles()

try
$roles = $this->user->getPagesForRoles(Auth::user()->id);
foreach ($roles as $key => $role)
if ($role['hasRole'] == 0)
unset($roles[$key]);



return response()->json([
'data' => $roles
], 200
);

catch (Exception $e)
return response()->json([
'message' => $e->getMessage(),
'line' => $e->getLine()
], 400
);





And my model code (AppUser) for obtaining the roles...



public function getPagesForRoles($userID = false)

if (!$userID)
$userID = Auth::user()->id;


$pagesForRoles = $this->role->getRoles();

// check if user has role or not and add it to data
if ($userID != 0)

foreach ($pagesForRoles as $key => &$role)
$hasRole = DB::table('user_roles')
->where('role_id', '=', $key)
->where('user_id', '=', $userID)
->get();

if (isset($hasRole[0]))
if($key == 'admin')
$hasAdminRole = 1;

$role['hasRole'] = 1;
else
$role['hasRole'] = 0;




if($userID == 1


getRoles() that is called in the model code simply returns a hardcoded array.



EDIT: Its worth mentioning that when I do die('test'); in my controller function I do get a response every time.










share|improve this question
























  • Have you looked into server and Laravel logs? If it’s intermittent, it might be due to throttling (which you don’t have) or a caching issue.

    – Daniel Protopopov
    Oct 16 '18 at 19:27






  • 1





    Ill take a look at the server logs. Actually even writing out the question has helped in really realising there isnt anything wrong in the code.

    – Adrian
    Oct 17 '18 at 9:18











  • The screenshot for the failed call seems to indicate that the request hasn't finished processing. There is no response error code like 200 or otherwise. Are you sure the call has finished?

    – Niraj Shah
    Oct 17 '18 at 13:22











  • Pretty sure alright, it sits there indefinitely, but yes it seems like what you're describing is whats happening.

    – Adrian
    Oct 17 '18 at 14:41











  • This isnt happening in Chrome for some reason, only Firefox and Edge.

    – Adrian
    Oct 18 '18 at 14:39















0















IMPORTANT EDIT: I cannot seem to be able to replicate the issue on Chrome, it is intermittent on Firefox (about 50/50). And is happening even more on Edge (about 70/30).



I have checked other similar questions but they do not resolve the issue.



I am using Angular JS with Laravel 5.4, sending a GET request and it is sometimes succeeding and sometimes failing. When I say failing I mean I am literally getting nothing back. I am getting no error and I can confirm laravel.log file is logging other errors but nothing for this.



In my console I have two examples that were done one after the other.



The request is called get-user-roles and the function is called at UserController@getUserRoles



Failed:
enter image description here



Succeeded:
enter image description here
You can see in the second one I am getting blank data back as expected.



Here is my web.php in /routes



Route::group(
[
'middleware' => ['cors', 'switchdb'],

], function ()

// auth

Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]);
Route::post('authenticate', 'AuthenticateController@authenticate');

Route::group(
[
'middleware' => ['jwt.auth'],

], function ()
Route::get('get-user-roles', 'UserController@getUserRoles');
);

Route::group(
[
'middleware' => ['jwt.auth', 'is-not-customer'],

], function ()
// more functions
);
);


Here is my controller UserController



<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppUser;
use AppRole;
use AppHttpRequestsPublishUserRequest;
use AppHttpRequestsChangePasswordRequest;
use Auth;


class UserController extends Controller


protected $user;

public function __construct()

$this->user = new User();


public function getUserRoles()

try
$roles = $this->user->getPagesForRoles(Auth::user()->id);
foreach ($roles as $key => $role)
if ($role['hasRole'] == 0)
unset($roles[$key]);



return response()->json([
'data' => $roles
], 200
);

catch (Exception $e)
return response()->json([
'message' => $e->getMessage(),
'line' => $e->getLine()
], 400
);





And my model code (AppUser) for obtaining the roles...



public function getPagesForRoles($userID = false)

if (!$userID)
$userID = Auth::user()->id;


$pagesForRoles = $this->role->getRoles();

// check if user has role or not and add it to data
if ($userID != 0)

foreach ($pagesForRoles as $key => &$role)
$hasRole = DB::table('user_roles')
->where('role_id', '=', $key)
->where('user_id', '=', $userID)
->get();

if (isset($hasRole[0]))
if($key == 'admin')
$hasAdminRole = 1;

$role['hasRole'] = 1;
else
$role['hasRole'] = 0;




if($userID == 1


getRoles() that is called in the model code simply returns a hardcoded array.



EDIT: Its worth mentioning that when I do die('test'); in my controller function I do get a response every time.










share|improve this question
























  • Have you looked into server and Laravel logs? If it’s intermittent, it might be due to throttling (which you don’t have) or a caching issue.

    – Daniel Protopopov
    Oct 16 '18 at 19:27






  • 1





    Ill take a look at the server logs. Actually even writing out the question has helped in really realising there isnt anything wrong in the code.

    – Adrian
    Oct 17 '18 at 9:18











  • The screenshot for the failed call seems to indicate that the request hasn't finished processing. There is no response error code like 200 or otherwise. Are you sure the call has finished?

    – Niraj Shah
    Oct 17 '18 at 13:22











  • Pretty sure alright, it sits there indefinitely, but yes it seems like what you're describing is whats happening.

    – Adrian
    Oct 17 '18 at 14:41











  • This isnt happening in Chrome for some reason, only Firefox and Edge.

    – Adrian
    Oct 18 '18 at 14:39













0












0








0








IMPORTANT EDIT: I cannot seem to be able to replicate the issue on Chrome, it is intermittent on Firefox (about 50/50). And is happening even more on Edge (about 70/30).



I have checked other similar questions but they do not resolve the issue.



I am using Angular JS with Laravel 5.4, sending a GET request and it is sometimes succeeding and sometimes failing. When I say failing I mean I am literally getting nothing back. I am getting no error and I can confirm laravel.log file is logging other errors but nothing for this.



In my console I have two examples that were done one after the other.



The request is called get-user-roles and the function is called at UserController@getUserRoles



Failed:
enter image description here



Succeeded:
enter image description here
You can see in the second one I am getting blank data back as expected.



Here is my web.php in /routes



Route::group(
[
'middleware' => ['cors', 'switchdb'],

], function ()

// auth

Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]);
Route::post('authenticate', 'AuthenticateController@authenticate');

Route::group(
[
'middleware' => ['jwt.auth'],

], function ()
Route::get('get-user-roles', 'UserController@getUserRoles');
);

Route::group(
[
'middleware' => ['jwt.auth', 'is-not-customer'],

], function ()
// more functions
);
);


Here is my controller UserController



<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppUser;
use AppRole;
use AppHttpRequestsPublishUserRequest;
use AppHttpRequestsChangePasswordRequest;
use Auth;


class UserController extends Controller


protected $user;

public function __construct()

$this->user = new User();


public function getUserRoles()

try
$roles = $this->user->getPagesForRoles(Auth::user()->id);
foreach ($roles as $key => $role)
if ($role['hasRole'] == 0)
unset($roles[$key]);



return response()->json([
'data' => $roles
], 200
);

catch (Exception $e)
return response()->json([
'message' => $e->getMessage(),
'line' => $e->getLine()
], 400
);





And my model code (AppUser) for obtaining the roles...



public function getPagesForRoles($userID = false)

if (!$userID)
$userID = Auth::user()->id;


$pagesForRoles = $this->role->getRoles();

// check if user has role or not and add it to data
if ($userID != 0)

foreach ($pagesForRoles as $key => &$role)
$hasRole = DB::table('user_roles')
->where('role_id', '=', $key)
->where('user_id', '=', $userID)
->get();

if (isset($hasRole[0]))
if($key == 'admin')
$hasAdminRole = 1;

$role['hasRole'] = 1;
else
$role['hasRole'] = 0;




if($userID == 1


getRoles() that is called in the model code simply returns a hardcoded array.



EDIT: Its worth mentioning that when I do die('test'); in my controller function I do get a response every time.










share|improve this question
















IMPORTANT EDIT: I cannot seem to be able to replicate the issue on Chrome, it is intermittent on Firefox (about 50/50). And is happening even more on Edge (about 70/30).



I have checked other similar questions but they do not resolve the issue.



I am using Angular JS with Laravel 5.4, sending a GET request and it is sometimes succeeding and sometimes failing. When I say failing I mean I am literally getting nothing back. I am getting no error and I can confirm laravel.log file is logging other errors but nothing for this.



In my console I have two examples that were done one after the other.



The request is called get-user-roles and the function is called at UserController@getUserRoles



Failed:
enter image description here



Succeeded:
enter image description here
You can see in the second one I am getting blank data back as expected.



Here is my web.php in /routes



Route::group(
[
'middleware' => ['cors', 'switchdb'],

], function ()

// auth

Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]);
Route::post('authenticate', 'AuthenticateController@authenticate');

Route::group(
[
'middleware' => ['jwt.auth'],

], function ()
Route::get('get-user-roles', 'UserController@getUserRoles');
);

Route::group(
[
'middleware' => ['jwt.auth', 'is-not-customer'],

], function ()
// more functions
);
);


Here is my controller UserController



<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppUser;
use AppRole;
use AppHttpRequestsPublishUserRequest;
use AppHttpRequestsChangePasswordRequest;
use Auth;


class UserController extends Controller


protected $user;

public function __construct()

$this->user = new User();


public function getUserRoles()

try
$roles = $this->user->getPagesForRoles(Auth::user()->id);
foreach ($roles as $key => $role)
if ($role['hasRole'] == 0)
unset($roles[$key]);



return response()->json([
'data' => $roles
], 200
);

catch (Exception $e)
return response()->json([
'message' => $e->getMessage(),
'line' => $e->getLine()
], 400
);





And my model code (AppUser) for obtaining the roles...



public function getPagesForRoles($userID = false)

if (!$userID)
$userID = Auth::user()->id;


$pagesForRoles = $this->role->getRoles();

// check if user has role or not and add it to data
if ($userID != 0)

foreach ($pagesForRoles as $key => &$role)
$hasRole = DB::table('user_roles')
->where('role_id', '=', $key)
->where('user_id', '=', $userID)
->get();

if (isset($hasRole[0]))
if($key == 'admin')
$hasAdminRole = 1;

$role['hasRole'] = 1;
else
$role['hasRole'] = 0;




if($userID == 1


getRoles() that is called in the model code simply returns a hardcoded array.



EDIT: Its worth mentioning that when I do die('test'); in my controller function I do get a response every time.







php angularjs laravel laravel-5 laravel-5.4






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 18 '18 at 16:39







Adrian

















asked Oct 16 '18 at 18:53









AdrianAdrian

1,04332574




1,04332574












  • Have you looked into server and Laravel logs? If it’s intermittent, it might be due to throttling (which you don’t have) or a caching issue.

    – Daniel Protopopov
    Oct 16 '18 at 19:27






  • 1





    Ill take a look at the server logs. Actually even writing out the question has helped in really realising there isnt anything wrong in the code.

    – Adrian
    Oct 17 '18 at 9:18











  • The screenshot for the failed call seems to indicate that the request hasn't finished processing. There is no response error code like 200 or otherwise. Are you sure the call has finished?

    – Niraj Shah
    Oct 17 '18 at 13:22











  • Pretty sure alright, it sits there indefinitely, but yes it seems like what you're describing is whats happening.

    – Adrian
    Oct 17 '18 at 14:41











  • This isnt happening in Chrome for some reason, only Firefox and Edge.

    – Adrian
    Oct 18 '18 at 14:39

















  • Have you looked into server and Laravel logs? If it’s intermittent, it might be due to throttling (which you don’t have) or a caching issue.

    – Daniel Protopopov
    Oct 16 '18 at 19:27






  • 1





    Ill take a look at the server logs. Actually even writing out the question has helped in really realising there isnt anything wrong in the code.

    – Adrian
    Oct 17 '18 at 9:18











  • The screenshot for the failed call seems to indicate that the request hasn't finished processing. There is no response error code like 200 or otherwise. Are you sure the call has finished?

    – Niraj Shah
    Oct 17 '18 at 13:22











  • Pretty sure alright, it sits there indefinitely, but yes it seems like what you're describing is whats happening.

    – Adrian
    Oct 17 '18 at 14:41











  • This isnt happening in Chrome for some reason, only Firefox and Edge.

    – Adrian
    Oct 18 '18 at 14:39
















Have you looked into server and Laravel logs? If it’s intermittent, it might be due to throttling (which you don’t have) or a caching issue.

– Daniel Protopopov
Oct 16 '18 at 19:27





Have you looked into server and Laravel logs? If it’s intermittent, it might be due to throttling (which you don’t have) or a caching issue.

– Daniel Protopopov
Oct 16 '18 at 19:27




1




1





Ill take a look at the server logs. Actually even writing out the question has helped in really realising there isnt anything wrong in the code.

– Adrian
Oct 17 '18 at 9:18





Ill take a look at the server logs. Actually even writing out the question has helped in really realising there isnt anything wrong in the code.

– Adrian
Oct 17 '18 at 9:18













The screenshot for the failed call seems to indicate that the request hasn't finished processing. There is no response error code like 200 or otherwise. Are you sure the call has finished?

– Niraj Shah
Oct 17 '18 at 13:22





The screenshot for the failed call seems to indicate that the request hasn't finished processing. There is no response error code like 200 or otherwise. Are you sure the call has finished?

– Niraj Shah
Oct 17 '18 at 13:22













Pretty sure alright, it sits there indefinitely, but yes it seems like what you're describing is whats happening.

– Adrian
Oct 17 '18 at 14:41





Pretty sure alright, it sits there indefinitely, but yes it seems like what you're describing is whats happening.

– Adrian
Oct 17 '18 at 14:41













This isnt happening in Chrome for some reason, only Firefox and Edge.

– Adrian
Oct 18 '18 at 14:39





This isnt happening in Chrome for some reason, only Firefox and Edge.

– Adrian
Oct 18 '18 at 14:39












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52842199%2flaravel-5-4-inconsistent-no-response-and-no-error-in-logs%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid …


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52842199%2flaravel-5-4-inconsistent-no-response-and-no-error-in-logs%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page