I just released a neat package that I’ve mentioned on these forums before: npdev:async-proxy. It creates a way to call Meteor methods using async/await, which is pretty neat.
One thing that is a little bit off though, is that if you use it in React, it works great client side, but Promises don’t seem to resolve in SSR like they do in meteor methods.
So my question is, how can I resolve this? In my project, I have a local fork of
npdev:async-proxy which has a separate implementation of the API for the server, and that API does not use a promise at all. On the client side, I use checks for isServer to make sure to either call it with await or not, but this is hacky. I’m wonder if there is a way to use Meteor.wrapAsync instead, but that would seem to conflict with await. What I’d really like is simply a way to tell React.renderToString (or React.renderToNodeStream) to resolve Promises it encounters, but maybe that’s just crazy talk!
What do you think?