Last active
August 29, 2015 14:11
-
-
Save cauethenorio/4d0109f98aa42b2ca691 to your computer and use it in GitHub Desktop.
Angular app configuration to add 1s fake latency to xhr json requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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