Can I use a REST api as a datasource in my meteor app?
My goal is to create a connection to a REST api via the app then have meteor update clients with the new data just like meteor does with mongodb data sources.
Is anyone currently doing this? If so can you share some details examples ect… ?
It is possible, your server would need to poll the rest API. Or the api would need to have the concept of pushing changes to your server via some webhook.
Whichever way you get the data, you would use the publication handles added/changed/removed methods to send those changes to the client. On the client side you declareca collection and use as normal
No, because it would likely be very dependent on what data you wanted to expose from the API and what data the API provides (single documents, multiple, nested, etc)
REST or Websockets don’t really matter to me I just wanted to know if anyone was using a datasource other than mongodb and it sounds as if it’s possible which was what I was after. @coagmano do you have an example of using websockets that you can share?
thx
In one of my projects I use a REST source on the server and Mongo collections that are not tied to an actual collection in mongodb to transfer the data to the client. Basically, a Method call to the server that performs the REST and returns the result which is put into a collection and can be accessed on the client the same way as if it had subscribed to a publication