Sails Helper Methods Refactoring
Fullstack Social iOS NodeJS REST
To help reduce code repetition in our projects, Sails comes with helper methods that allow you to extract logic inside of one location. Using this concept, I'll walk you through how to take our file uploading code and put it in a single file. Calling this code from multiple files is really easy and we'll see how to retrieve our upload file urls at the very end.

Comments (4)
Setwork44
3 years ago
Haha I'm definantly not getting the "trying to upload file with helper method".. something has seriously gone wrong and I simply have no idea what it is..
Setwork44
3 years ago
I literally had to cut all of my code and replace it with yours and it finally worked to upload the avatar. Just means that i will have to momentarily leave my desire to have the "job title" and "website"as editable text inputs on the users profile page...
Setwork44
3 years ago
Hey Brian, ive managed to fix the uploading of avatar. But now ive added my two extra fields "job title" and "website" those fields refresh as "undefined" after i type something then save it. I feel like this is a simple error that I maybe missing, do you have any idea as to what that might be?
Brian Voong
3 years ago
Setwork44
3 years ago
youre not gonna believe this man, i found the problem! I wrote "this.jobTitle" when i should have written "this.user.jobtitle" I cant believe it! its all working now. And yes I will take heed as to your 3 steps. Brian honestly when I get to the end of this course im going to fly to Cali and buy you a whole box of chocolates!!
JMan
2 years ago
I saw the issue that you had with the image that was too large during the end of the video.. maybe a good bonus lesson could be creating an image editor so that all images are fixed to a certain height and width? ?‍♂️
HELP & SUPPORT