Suporto codice async per iosdk

Buongiorno tutti,
I write in English because I am more familiar but feel free to respond, if you want, in Italian. Io capisco e leggo Italiano.
I have followed the iosdk event of few days back and I tried to create a Node template to retrieve data from Google sheets.
The code actually works but I have a problem. The Google API for Sheets is asynchrnous and there is no such a thing like a sync call to fetch data from Google sheets.
My understanding is that iosdk is expecting a main function to return synchronously a well formatted JSON. This is not immediately possible with Node and Google Node APIs.
So my question is: does it make sense to think about some for of support for asynchronous retrieve APIs? I mean to have the main function returning a Promise to the iosdk?
Google APIs are one case, but it can well be the case that other will pop up.
Thanks in advance

Actually OpenWhisk IS asynchrounous.

You can return as a result of an action (and an import is an action) a Promise (as explained in my book :)). So you can build your code as as promise, and wrap every asynchronous code in a Promise.

For example:

  return new Promise(function(resolve, reject) {
           doSomethingAsynchronous( function callback() {
                   // extra code
                  resolve(result)
         })

Contact me in private for a copy of my book (free!).

Michele,
thanks for your answer.
So I understand that I can create an import.js file along these lines

function main(args) {
    const myPromise = buildMyPromiseSomehow(....);
    return myPromise;
}

Am I right?
Thanks in advance

by the way, how can I contact you in private?

Yes, that is correct. As long as you build a promise, the runtime will wait until it is resolved before returning the answer.

You can contact me in private no worries. The best way is usually through my Linkedin profile. Note that when discussing technicalities I love to do in public as people can find them searching in the forum if they face similar issues.