I use curl to make a call to the API like this:
$curl = curl_init();
if (isset($_COOKIE['session'])) {
curl_setopt($curl, CURLOPT_COOKIE, 'session=' . $_COOKIE['session']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $query_url);
$result = curl_exec($curl);
}
else {
$result = 'Cookie is expired';
}
curl_close($curl);
print $result;
Then I run this PHP file to test it and during testing when I load the file I receive nothing, when I restart the page I get the data that I need. When I use it with javascript behavior is similar.
When I test it with Postman, it works just fine.
Why doesn't it wait for a response and returns it to me then, but rather sends me the empty page first time around and only after page reload it returns a proper response?
Edit: JSON return is quite huge so it usually take a server around 1.5-2 seconds to return it