I know there are quite a few threads on this topic already, but unfortunately I didn\'t find my answer until now. I use angular.js with the example code from http://angular-js.i
It seems that your issue is not related to the image.
According to your code, the error message TypeError: Cannot set property 'avatar' of null means that the variable user is null.
And user is the result of findById(index.findUserId(req)).
So you should try to understand why this part is returning null.