problems requesting site via REST using 'isomorphic-fetch'

Hey guys!

I'm using:
import fetch from 'isomorphic-fetch'

and the code:
return fetch(`/condominio/index.php/test`)
      .then(req => req.json())
      .then(json => dispatch(receivePosts(subreddit, json)))

with Redux. The problem is that when the page loads the Application\Controller\Test php file doesn't check if the user is logged in. I'm using this code in order to get that:
namespace Application\Controller;
defined('C5_EXECUTE') or die("Access Denied.");
use Concrete\Core\Controller\Controller;
// use \Concrete\Core\Http\Request;
use Concrete\Core\Http\Request;
use Concrete\Core\User\User;
use Core;
// use User;
use Group;
use UserInfo;
class Test extends Controller
  public function processReq(Request $request)

At first when page is loaded I get user is not logged in, but when I click on edit and resend on Firefox the user is logged in and I get the requested information. Why is this happening? What am I missing on the code? Why does the first time doesn't work but in the second it does?

Thank you for your help

View Replies:
titanve replied on at Permalink Reply
Hey guys!

Reviewing the difference between both hearders (first call and second), I can notice that in the first one there is no Cookie (CONCRETE5=rbab7edk1294k77vlvffp2ea16) but there is one on the second call

Maybe that is the problem...
titanve replied on at Permalink Reply
The problem was that
doesn't send cookies by default so I had to modify the code to:

return fetch(`/condominio/index.php/test`, {
  credentials: 'same-origin'

Have a great night/day
sirRodgePodge replied on at Permalink Reply
That was indeed the problem, I ran into it too, I actually made a library to avoid dealing with this and to solve that annoying extra promise in parsing the response: