Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save timelf123/6c32c5ce5b87a3da1c0e5b47c73911eb to your computer and use it in GitHub Desktop.

Select an option

Save timelf123/6c32c5ce5b87a3da1c0e5b47c73911eb to your computer and use it in GitHub Desktop.
addTrailingSlashApiInterceptor.service.js
app.factory('addTrailingSlashApiInterceptor', function ($q) {
return {
'request': function(config) {
if (config.url.indexOf('/api/') != -1 && config.url.slice(-1) != '/') {
config.url += '/';
}
return config || $q.when(config);
}
};
});
app.config(function($httpProvider) {
$httpProvider.interceptors.push('myHttpInterceptor');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment