I have an API route that is being refactored to use ES6 promises to avoid callback hell.
After successfully converting to a promise chain, I wanted to export my .then()
functions to a separate file for cleanliness and clarity.
This works fine. However, what I'd like to do is move the functions declared in the Class constructor()
function into independent methods, which can reference the values instantiated by the constructor. That way it all reads nicer.
But, when I do, I run into scoping problems - this
is not defined, etc. What is the correct way to do this? Is an ES6 appropriate to use here, or should I use some other structure?
via Zfalen
No comments:
Post a Comment