If that is what you want:
return value2; // I would want to return value1 and value2 both
then return an array:
return [value1, value2];
or an object:
return { value1, value2 };
What async
/await
can return (which, by the way, is not what you have in your examples, despite the title of your question) is the same as what a promise can be resolved to, which is always a single value - but that single value can be an array or an object.
The problem that you describe, i.e. a callback function getting more than one non-error arguments and promises being resolved with a single value is an impedance mismatch between traditional Node-style error-first callbacks and promises (or async
/await
). This is demonstrated on the example of modules like request-promise
:
that promisify callback-style modules like request
:
that sometime allow for more than one value passed as callback arguments.
This is by the way caused by an asymmetry between function arguments and return statements. Some languages support only single-argument functions - sometimes with convenient syntax so you don't even know about it - and some languages support multiple values returned from functions. JavaScript supports multiple arguments but single returned values so what can be passed as arguments is not the same as what can be returned (unless you treat all arguments as a single array, that is).