I have a main function that is used to perform a specific query and parse the response. The first step in that function is validating the parameters given to that function. Then I will generate the query, sign it and then send it. For last, I will handle the response.
For sending the query, I would want to use the promise pattern. What I would want is that the main function would return a promise. The problem is, that most of the functions are sync and not async, so I shouldn't use promise. What I would want is something like this:
You can use
Promise.resolve() to start a promise chain and then use synchronous (and possibly throwing) functions as
return Promise.resolve(attributes) .then(this.validateQueryAttributes) // you might need .bind(this) .then(generateQuery) .then(signQuery) .then(sendQuery) .then(handleResponse);