angular-middleware
angular-middleware copied to clipboard
plugins.js:2 TypeError: Cannot read property 'next' of undefined
Hi,
I always get those error when setup the middleware. here is my code:
$middlewareProvider.map({
'check-token': ['Auth', (Auth) => {
const request = this;
Auth.get({ url: 'check-token' }, response => {
if (response) {
return request.next();
}
});
}]
});
I haven't tried it yet, but it looks like you are using those new fancy arrow functions, which implicitly binds "this" to the parent object. I think, but I'm not sure without checking, that "this" is actually referencing the map object and not the request. Give it a try without the arrow functions and let me know. I'll be happy to look into it more if that's not the case.