Skip to content

Instantly share code, notes, and snippets.

@cauethenorio
Last active August 29, 2015 14:11
Show Gist options
  • Save cauethenorio/4d0109f98aa42b2ca691 to your computer and use it in GitHub Desktop.
Save cauethenorio/4d0109f98aa42b2ca691 to your computer and use it in GitHub Desktop.
Angular app configuration to add 1s fake latency to xhr json requests
app.config(function ($httpProvider) {
$httpProvider.interceptors.push(
function ($q, $timeout) {
return {
'response': function (response) {
var deferred = $q.defer();
if (response.headers('content-type') == 'application/json')
$timeout(function() {deferred.resolve(response);}, 1000);
else
deferred.resolve(response);
return deferred.promise;
}
}
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment