Calling $http.get() multiple times always returns cached result

ⅰ亾dé卋堺 提交于 2019-12-12 04:07:32

问题


I have an angular controller that makes repeated gets via the $http object, like this:

$scope.refresh = function() 
{
    let url = 'api/get-status';
    $http.get( url ).then( function( response )
    {
        console.log( response.data );
    });
};

$scope.intervalFunction = function() 
{
    $timeout( function() 
    {
        $scope.refresh();
        $scope.intervalFunction();
    }, 2000 ) // msec
};

$scope.refresh();
$scope.intervalFunction();

The fetches appear to happen. When I do this in chrome I see the results coming back as expected in the console - except the result is just a repeat of the same content I get from the first result.

Whats extra inexplicable is I can turn off the server and the code continues to run without errors. When I look in the chrome's network view, chrome claims its continuing to make successful calls to the server.

Its as if the browser itself is returning cached results and lying about the fetches its making.

来源:https://stackoverflow.com/questions/36346796/calling-http-get-multiple-times-always-returns-cached-result

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!