Im writing a mobile application. It connects to the node.js server and getting some data. Which is the best way to retrieving data from nodejs server?
My project architecture:
mySQL DB <-> node.js (Server) <--(socket.io or restful)--> mobile clients
If you need a bidirectional real-time connection between your server and your client (e.g. a chat bot or a stock ticker), then socket.io would be a good choice.
However if you just need to fetch some data from time to time on the client from the server (and / or push some data), then a RESTful architecture makes more sense.
For most use cases a RESTful architecture is probably better. If you elaborate a bit more about what kind of data you're sharing between the client and the server, there could be a more precise answer.